$ 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 0xa2e37afd.
Command (m forhelp): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default 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): +256M Partition 1 of type Linux and of size 256 MiB is set
Command (m forhelp): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): Using default response p Partition number (2-4, default 2): First sector (526336-20971519, default 526336): Using default value 526336 Last sector, +sectors or +size{K,M,G} (526336-20971519, default 20971519): +256M Partition 2 of type Linux and of size 256 MiB is set
Command (m forhelp): t Partition number (1,2, default 2): 1 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM'
Command (m forhelp): t Partition number (1,2, default 2): 2 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM'
Command (m forhelp): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
# 格式化 LV $ sudo mkfs.ext4 /dev/shazam/storage mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 102400 inodes, 409600 blocks 20480 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=34078720 50 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done
$ sudo fdisk /dev/vdb [sudo] password for student: 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.
Command (m forhelp): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): Using default response p Partition number (3,4, default 3): First sector (1050624-20971519, default 1050624): Using default value 1050624 Last sector, +sectors or +size{K,M,G} (1050624-20971519, default 20971519): +800M Partition 3 of type Linux and of size 800 MiB is set
Command (m forhelp): t Partition number (1-3, default 3): Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM'
Command (m forhelp): w The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
$ sudo vgextend shazam /dev/vdb3 Volume group "shazam" successfully extended $ sudo vgdisplay shazam --- Volume group --- VG Name shazam System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 3 Act PV 3 VG Size 1.27 GiB PE Size 4.00 MiB Total PE 325 Alloc PE / Size 100 / 400.00 MiB Free PE / Size 225 / 900.00 MiB VG UUID s4g8vT-JCW9-p84f-wVU1-0dsn-xkrh-vytTVc
$ sudo resize2fs /dev/shazam/storage resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/shazam/storage is mounted on /storage; on-line resizing required old_desc_blocks = 4, new_desc_blocks = 8 The filesystem on /dev/shazam/storage is now 1048576 blocks long.