Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x1825a331.
Command (m forhelp): bn Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-20971519, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +1G Partition 1 of type Linux and of size 1 GiB is set
Command (m forhelp): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
$ sudo fdisk /dev/vdb Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x7db6d48a.
Command (m forhelp): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-20971519, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +500MB Partition 1 of type Linux and of size 500 MiB is set
Command (m forhelp): t Selected partition 1 Hex code (type L to list all codes): 82 Changed type of partition 'Linux' to 'Linux swap / Solaris'
Command (m forhelp): p
Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x7db6d48a
Device Boot Start End Blocks Id System /dev/vdb1 2048 1026047 512000 82 Linux swap / Solaris
Command (m forhelp): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
2、格式化 partition
1 2 3
$ sudo mkswap /dev/vdb1 Setting up swapspace version 1, size = 511996 KiB no label, UUID=ffb162b9-c1e6-4ce9-bde7-964b3ce9c43a
3、編輯 /etc/fstab 並掛載
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
$ sudo mkswap /dev/vdb1 Setting up swapspace version 1, size = 511996 KiB no label, UUID=ffb162b9-c1e6-4ce9-bde7-964b3ce9c43a
$ sudo gdisk /dev/vdb Command (? forhelp): n Partition number (1-128, default 1): First sector (34-20971486, default = 2048) or {+-}size{KMGTP}: Last sector (2048-20971486, default = 20971486) or {+-}size{KMGTP}: +2G Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem'
Command (? forhelp): n Partition number (2-128, default 2): First sector (34-20971486, default = 4196352) or {+-}size{KMGTP}: Last sector (4196352-20971486, default = 20971486) or {+-}size{KMGTP}: +512M Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): 8200 Changed type of partition to 'Linux swap'
Command (? forhelp): n Partition number (3-128, default 3): First sector (34-20971486, default = 5244928) or {+-}size{KMGTP}: Last sector (5244928-20971486, default = 20971486) or {+-}size{KMGTP}: +512M Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): 8200 Changed type of partition to 'Linux swap'
Command (? forhelp): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!
Do you want to proceed? (Y/N): y OK; writing new GUID partition table (GPT) to /dev/vdb. The operation has completed successfully.