403Webshell
Server IP : 103.119.228.120  /  Your IP : 18.191.215.30
Web Server : Apache
System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : nobody ( 99)
PHP Version : 5.6.40
Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime
MySQL : ON |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : ON |  Pkexec : ON
Directory :  /usr/local/ssl/local/ssl/local/ssl/local/ssl/share/doc/util-linux-2.23.2/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/local/ssl/local/ssl/local/ssl/local/ssl/share/doc/util-linux-2.23.2/sfdisk.txt
Examples of the use of sfdisk 3.0 (to partition a disk)
Input lines have fields <start>,<size>,<type>... - see sfdisk.8.
Usually no <start> is given, and input lines start with a comma.

Before doing anything with a disk, make sure it is not in use;
unmount all its file systems, and say swapoff to its swap partitions.
(The final BLKRRPART ioctl will fail if anything else still uses
the disk, and you will have to reboot. It is easier to first make
sure that nothing uses the disk, e.g., by testing:
	% umount /dev/sdb1
	% sfdisk -R /dev/sdb
	BLKRRPART: Device or resource busy
      * Device busy for revalidation (usage=2)
	% swapoff /dev/sdb3
	% sfdisk -R /dev/sdb
      * sdb: sdb1 < sdb5 sdb6 > sdb3
	%
Note that the starred messages are kernel messages, that may be
logged somewhere, or written to some other console.
In sfdisk 3.01 sfdisk automatically does this check, unless told not to.)

1. One big partition:
	sfdisk /dev/hda << EOF
	;
	EOF

(If there was garbage on the disk before, you may get error messages
like: `ERROR: sector 0 does not have an msdos signature'
and `/dev/hda: unrecognized partition'. This does not matter
if you write an entirely fresh partition table anyway.)

The output will be:
-----------------------------------------------------------------------
Old situation:
...
New situation:
Units = cylinders of 208896 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls   #blocks   Id  System
/dev/hda1          0+   1023    1024-   208895+  83  Linux native
Successfully wrote the new partition table
  hda: hda1
-----------------------------------------------------------------------
Writing and rereading the partition table takes a few seconds -
don't be alarmed if nothing happens for six seconds or so.


2. Three primary partitions: two of size 50MB and the rest:
	sfdisk /dev/hda -uM << EOF
	,50
	,50
	;
	EOF
-----------------------------------------------------------------------
New situation:
Units = megabytes of 1048576 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start   End     MB   #blocks   Id  System
/dev/hda1         0+    50-    51-    51203+  83  Linux native
/dev/hda2        50+   100-    51-    51204   83  Linux native
/dev/hda3       100+   203    104-   106488   83  Linux native
Successfully wrote the new partition table
  hda: hda1 hda2 hda3
-----------------------------------------------------------------------
/dev/hda1 is one block (in fact only half a block) shorter than
/dev/hda2 because its start had to be shifted away from zero in
order to leave room for the Master Boot Record (MBR).


3. A 1MB OS2 Boot Manager partition, a 50MB DOS partition,
   and three extended partitions (DOS D:, Linux swap, Linux):
	sfdisk /dev/hda -uM << EOF
	,1,a
	,50,6
	,,E
	;
	,20,4
	,16,S
	;
	EOF
-----------------------------------------------------------------------
   Device Boot Start   End     MB   #blocks   Id  System
/dev/hda1         0+     1-     2-     1223+   a  OS/2 Boot Manager
/dev/hda2         1+    51-    51-    51204    6  DOS 16-bit FAT >=32M
/dev/hda3        51+   203    153-   156468    5  Extended
/dev/hda4         0      -      0         0    0  Empty
/dev/hda5        51+    71-    21-    20603+   4  DOS 16-bit FAT <32M
/dev/hda6        71+    87-    17-    16523+  82  Linux swap
/dev/hda7        87+   203    117-   119339+  83  Linux native
Successfully wrote the new partition table
  hda: hda1 hda2 hda3 < hda5 hda6 hda7 >
-----------------------------------------------------------------------
All these rounded numbers look better in cylinder units:
	% sfdisk -l /dev/hda
-----------------------------------------------------------------------
   Device Boot Start     End   #cyls   #blocks   Id  System
/dev/hda1          0+      5       6-     1223+   a  OS/2 Boot Manager
/dev/hda2          6     256     251     51204    6  DOS 16-bit FAT >=32M
/dev/hda3        257    1023     767    156468    5  Extended
/dev/hda4          0       -       0         0    0  Empty
/dev/hda5        257+    357     101-    20603+   4  DOS 16-bit FAT <32M
/dev/hda6        358+    438      81-    16523+  82  Linux swap
/dev/hda7        439+   1023     585-   119339+  83  Linux native
-----------------------------------------------------------------------
But still - why does /dev/hda5 not start on a cylinder boundary?
Because it is contained in an extended partition that does.
Of the chain of extended partitions, usually only the first is
shown. (The others have no name under Linux anyway.) But
these additional extended partitions can be made visible:
	% sfdisk -l -x /dev/hda
-----------------------------------------------------------------------
   Device Boot Start     End   #cyls   #blocks   Id  System
/dev/hda1          0+      5       6-     1223+   a  OS/2 Boot Manager
/dev/hda2          6     256     251     51204    6  DOS 16-bit FAT >=32M
/dev/hda3        257    1023     767    156468    5  Extended
/dev/hda4          0       -       0         0    0  Empty

/dev/hda5        257+    357     101-    20603+   4  DOS 16-bit FAT <32M
    -            358    1023     666    135864    5  Extended
    -            257     256       0         0    0  Empty
    -            257     256       0         0    0  Empty

/dev/hda6        358+    438      81-    16523+  82  Linux swap
    -            439    1023     585    119340    5  Extended
    -            358     357       0         0    0  Empty
    -            358     357       0         0    0  Empty

/dev/hda7        439+   1023     585-   119339+  83  Linux native
    -            439     438       0         0    0  Empty
    -            439     438       0         0    0  Empty
    -            439     438       0         0    0  Empty
-----------------------------------------------------------------------

Why the empty 4th input line? The description of the extended partitions
starts after that of the four primary partitions.
You force an empty partition with a ",0" input line, but here all
space was divided already, so the fourth partition became empty
automatically.

How did I know about 4,6,a,E,S? Well, E,S,L stand for Extended,
Swap and Linux. The other values are hexadecimal and come from
the table:
	% sfdisk -T
	Id  Name
	
	 0  Empty
	 1  DOS 12-bit FAT
	 2  XENIX root
	 3  XENIX usr
	 4  DOS 16-bit FAT <32M
	 5  Extended
	 6  DOS 16-bit FAT >=32M
	 7  OS/2 HPFS or QNX or Advanced UNIX
	 8  AIX data
	 9  AIX boot or Coherent
	 a  OS/2 Boot Manager
	...


4. Preserving the sectors changed by sfdisk.
	% sfdisk -O save-hdd-partition-sectors /dev/hda
        ...
   will write the sectors overwritten by sfdisk to file.
   If you notice that you trashed some partition, you may
   be able to restore things by
	% sfdisk -I save-hdd-partition-sectors /dev/hda
	%

5. Preserving some old partitions.
	% sfdisk -N2 /dev/hda
	...
   will only change the partition /dev/hda2, and leave the rest
   unchanged. The most obvious application is to change an Id:
	% sfdisk -N7 /dev/hda
	,,63
	%
-----------------------------------------------------------------------
Old situation:

   Device Boot Start     End   #cyls   #blocks   Id  System
/dev/hda1          0+      5       6-     1223+   a  OS/2 Boot Manager
...
/dev/hda6        358+    438      81-    16523+  82  Linux swap
/dev/hda7        439+   1023     585-   119339+  83  Linux native

New situation:

   Device Boot Start     End   #cyls   #blocks   Id  System
/dev/hda1          0+      5       6-     1223+   a  OS/2 Boot Manager
...
/dev/hda6        358+    438      81-    16523+  82  Linux swap
/dev/hda7        439+   1023     585-   119339+  63  GNU HURD
-----------------------------------------------------------------------
   Note that changing a logical partition into an empty partition
   will decrease the number of all subsequent logical partitions.   

6. Deleting a partition.
At first I thought of having an option -X# for deleting partitions,
but there are several ways in which a partition can be deleted, and
it is probably better to handle this just as a general change.
	% sfdisk -d /dev/hda > ohda
will write the current tables on the file `ohda'.
-----------------------------------------------------------------------
% cat ohda
# partition table of /dev/hda
unit: sectors

/dev/hda1 : start=        1, size=   40799, Id= 5
/dev/hda2 : start=    40800, size=   40800, Id=83
/dev/hda3 : start=    81600, size=  336192, Id=83
/dev/hda4 : start=        0, size=       0, Id= 0
/dev/hda5 : start=        2, size=   40798, Id=83
-----------------------------------------------------------------------
In order to delete the partition on /dev/hda3, edit this file
and feed the result to sfdisk again.
-----------------------------------------------------------------------
% emacs ohda
% cat ohda
# partition table of /dev/hda
unit: sectors

/dev/hda1 : start=        1, size=   40799, Id= 5
/dev/hda2 : start=    40800, size=   40800, Id=83
/dev/hda3 : start=        0, size=       0, Id= 0
/dev/hda4 : start=        0, size=       0, Id= 0
/dev/hda5 : start=        2, size=   40798, Id=83
% sfdisk /dev/hda < ohda
Old situation:
Units = cylinders of 208896 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls   #blocks   Id  System
/dev/hda1          0+     99     100-    20399+   5  Extended
/dev/hda2        100     199     100     20400   83  Linux native
/dev/hda3        200    1023     824    168096   83  Linux native
/dev/hda4          0       -       0         0    0  Empty
/dev/hda5          0+     99     100-    20399   83  Linux native
New situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End  #sectors  Id  System
/dev/hda1             1     40799     40799   5  Extended
/dev/hda2         40800     81599     40800  83  Linux native
/dev/hda3             0         -         0   0  Empty
/dev/hda4             0         -         0   0  Empty
/dev/hda5             2     40799     40798  83  Linux native
Successfully wrote the new partition table
% sfdisk -l -V /dev/hda

Disk /dev/hda: 12 heads, 34 sectors, 1024 cylinders
Units = cylinders of 208896 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls   #blocks   Id  System
/dev/hda1          0+     99     100-    20399+   5  Extended
/dev/hda2        100     199     100     20400   83  Linux native
/dev/hda3          0       -       0         0    0  Empty
/dev/hda4          0       -       0         0    0  Empty
/dev/hda5          0+     99     100-    20399   83  Linux native
/dev/hda: OK
-----------------------------------------------------------------------
This is a good way of making changes: dump the current status
to file, edit the file, and feed it to sfdisk.
Preserving the file on some other disk could be useful:
if ever the MBR gets thrashed it can be used to restore
the old situation.

Youez - 2016 - github.com/yon3zu
LinuXploit