部署一個客戶環境,重裝了ubuntu server 10.04,用的lvm管理。
500G的硬盤開始劃了250G給系統分區,剩下的空間想再劃分個掛載,只記得lvcreate了,上網搜搜把命令整理了下。
dhuser@dhserver:~$ cd /
dhuser@dhserver:/$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/dhserver-root
264G 1.7G 249G 1% /
none 2.0G 184K 2.0G 1% /dev
none 2.0G 0 2.0G 0% /dev/shm
none 2.0G 44K 2.0G 1% /var/run
none 2.0G 0 2.0G 0% /var/lock
none 2.0G 0 2.0G 0% /lib/init/rw
none 264G 1.7G 249G 1% /var/lib/ureadahead/debugfs
/dev/sda1 228M 33M 184M 16% /boot
dhuser@dhserver:/$ sudo su
root@dhserver:/# vgscan
Reading all physical volumes. This may take a while...
Found volume group "dhserver" using metadata type lvm2
root@dhserver:/# vgdisplay
--- Volume group ---
VG Name dhserver
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 465.52 GiB
PE Size 4.00 MiB
Total PE 119173
Alloc PE / Size 71477 / 279.21 GiB
Free PE / Size 47696 / 186.31 GiB
VG UUID bxBdJI-Nk41-1ymb-QufC-vTVF-HAHF-Lewfbc
root@dhserver:/# lvscan
ACTIVE '/dev/dhserver/root' [267.90 GiB] inherit
ACTIVE '/dev/dhserver/swap_1' [11.30 GiB] inherit
root@dhserver:/# lvdisplay
--- Logical volume ---
LV Name /dev/dhserver/root
VG Name dhserver
LV UUID NuElXa-jIz9-La7Q-1tIJ-zfPy-EeXr-zwo8oN
LV Write Access read/write
LV Status available
# open 1
LV Size 267.90 GiB
Current LE 68583
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 251:0
--- Logical volume ---
LV Name /dev/dhserver/swap_1
VG Name dhserver
LV UUID RskUQN-ihTx-PitH-G2Bn-TKZG-2vh3-hZPu52
LV Write Access read/write
LV Status available
# open 1
LV Size 11.30 GiB
Current LE 2894
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 251:1
root@dhserver:/# pvscan
PV /dev/sda5 VG dhserver lvm2 [465.52 GiB / 186.31 GiB free]
Total: 1 [465.52 GiB] / in use: 1 [465.52 GiB] / in no VG: 0 [0 ]
root@dhserver:/# lvcreate -L 180G -n lvdata dhserver
Logical volume "lvdata" created
root@dhserver:/# pvscan
PV /dev/sda5 VG dhserver lvm2 [465.52 GiB / 6.31 GiB free]
Total: 1 [465.52 GiB] / in use: 1 [465.52 GiB] / in no VG: 0 [0 ]
root@dhserver:/# lvdisplay
--- Logical volume ---
LV Name /dev/dhserver/root
VG Name dhserver
LV UUID NuElXa-jIz9-La7Q-1tIJ-zfPy-EeXr-zwo8oN
LV Write Access read/write
LV Status available
# open 1
LV Size 267.90 GiB
Current LE 68583
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 251:0
--- Logical volume ---
LV Name /dev/dhserver/swap_1
VG Name dhserver
LV UUID RskUQN-ihTx-PitH-G2Bn-TKZG-2vh3-hZPu52
LV Write Access read/write
LV Status available
# open 1
LV Size 11.30 GiB
Current LE 2894
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 251:1
--- Logical volume ---
LV Name /dev/dhserver/lvdata
VG Name dhserver
LV UUID 7Cegl5-h0B2-6Nck-DeHU-jgT0-XrlN-iRe86k
LV Write Access read/write
LV Status available
# open 0
LV Size 180.00 GiB
Current LE 46080
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 251:2
root@dhserver:/# mkfs.ext4 /dev/dhserver/lvdata
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
11796480 inodes, 47185920 blocks
2359296 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1440 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
root@dhserver:/# mkdir /data
root@dhserver:/# mount /dev/dhserver/lvdata /data
root@dhserver:/# cd /data
root@dhserver:/data# ll
total 24
drwxr-xr-x 3 root root 4096 2012-12-18 16:29 ./
drwxr-xr-x 24 root root 4096 2012-12-18 16:30 ../
drwx------ 2 root root 16384 2012-12-18 16:29 lost+found/
大功告成,再加到fstab裏讓系統啓動時自動掛載就好了。
root@dhserver:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
/dev/mapper/dhserver-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=7e0cf8d8-418d-4024-b20f-2fa116a54992 /boot ext2 defaults 0 2
/dev/mapper/dhserver-swap_1 none swap sw 0 0
/dev/mapper/dhserver-lvdata /data