vps数据盘、系统盘分区操作

admin 2014年10月25日 Linux学习 1181次阅读 查看评论

  vps数据盘、系统盘分区操作:

  [byrd@hk ~]$ sudo bash

  We trust you have received the usual lecture from the local System

  Administrator. It usually boils down to these three things:

  #1) Respect the privacy of others.

  #2) Think before you type.

  #3) With great power comes great responsibility.

  [sudo] password for byrd:

  [root@hk byrd]#

  Broadcast message from root@hk.t4x.org

  (/dev/pts/0) at 22:00 ...

  The system is going down for reboot NOW!

  Connection closed by foreign host.

  Type `help' to learn how to use Xshell prompt.

  Xshell:\>

  Connecting to 103.243.128.87:3XX97...

  Connection established.

  To escape to local shell, press 'Ctrl+Alt+]'.

  Last login: Mon May 5 21:40:47 2014 from 1.1.1.1

  [byrd@hk ~]$ sudo bash

  [sudo] password for byrd:

  [root@hk byrd]# fdisk -l

  Disk /dev/sda: 10.7 GB, 10737418240 bytes

  255 heads, 63 sectors/track, 1305 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00073ffb

  Device Boot Start End Blocks Id System

  /dev/sda1 * 1 64 512000 83 Linux

  Partition 1 does not end on cylinder boundary.

  /dev/sda2 64 1306 9972736 8e Linux LVM

  Disk /dev/sdb: 16.1 GB, 16106127360 bytes

  255 heads, 63 sectors/track, 1958 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0xcbc85cc2

  Device Boot Start End Blocks Id System

  Disk /dev/mapper/vg_cloud-lv_root: 8095 MB, 8095006720 bytes

  255 heads, 63 sectors/track, 984 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00000000

  Disk /dev/mapper/vg_cloud-lv_swap: 2113 MB, 2113929216 bytes

  255 heads, 63 sectors/track, 257 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00000000

  [root@hk byrd]# fdisk /dev/sdb

  WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

  switch off the mode (command 'c') and change display units to

  sectors (command 'u').

  Command (m for help): n

  Command action

  e extended

  p primary partition (1-4)

  p

  Partition number (1-4): 1

  First cylinder (1-1958, default 1): 1

  Last cylinder, +cylinders or +size{K,M,G} (1-1958, default 1958): +1G

  Command (m for help): M

  Command action

  a toggle a bootable flag

  b edit bsd disklabel

  c toggle the dos compatibility flag

  d delete a partition

  l list known partition types

  m print this menu

  n add a new partition

  o create a new empty DOS partition table

  p print the partition table

  q quit without saving changes

  s create a new empty Sun disklabel

  t change a partition's system id

  u change display/entry units

  v verify the partition table

  w write table to disk and exit

  x extra functionality (experts only)

  Command (m for help): T

  Selected partition 1

  Hex code (type L to list codes): 1

  Changed system type of partition 1 to 1 (FAT12)

  Command (m for help): t

  Selected partition 1

  Hex code (type L to list codes): 8e

  Changed system type of partition 1 to 8e (Linux LVM)

  Command (m for help): n

  Command action

  e extended

  p primary partition (1-4)

  p

  Partition number (1-4): 2

  First cylinder (133-1958, default 133): 133

  Last cylinder, +cylinders or +size{K,M,G} (133-1958, default 1958): +7G

  Command (m for help): p

  Disk /dev/sdb: 16.1 GB, 16106127360 bytes

  255 heads, 63 sectors/track, 1958 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0xcbc85cc2

  Device Boot Start End Blocks Id System

  /dev/sdb1 1 132 1060258+ 8e Linux LVM

  /dev/sdb2 133 1047 7349737+ 83 Linux

  Command (m for help): t

  Partition number (1-4): 2

  Hex code (type L to list codes): 8e

  Changed system type of partition 2 to 8e (Linux LVM)

  Command (m for help): n

  Command action

  e extended

  p primary partition (1-4)

  e

  Partition number (1-4): 1

  Partition 1 is already defined. Delete it before re-adding it.

  Command (m for help): n

  Command action

  e extended

  p primary partition (1-4)

  e

  Partition number (1-4): 5

  Value out of range.

  Partition number (1-4): 2

  Partition 2 is already defined. Delete it before re-adding it.

  Command (m for help): n

  Command action

  e extended

  p primary partition (1-4)

  e

  Partition number (1-4): 3

  First cylinder (1048-1958, default 1048):

  Using default value 1048

  Last cylinder, +cylinders or +size{K,M,G} (1048-1958, default 1958):

  Using default value 1958

  Command (m for help): p

  Disk /dev/sdb: 16.1 GB, 16106127360 bytes

  255 heads, 63 sectors/track, 1958 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0xcbc85cc2

  Device Boot Start End Blocks Id System

  /dev/sdb1 1 132 1060258+ 8e Linux LVM

  /dev/sdb2 133 1047 7349737+ 8e Linux LVM

  /dev/sdb3 1048 1958 7317607+ 5 Extended

  Command (m for help): n

  Command action

  l logical (5 or over)

  p primary partition (1-4)

  p

  Selected partition 4

  No free sectors available

  Command (m for help): w

  The partition table has been altered!

  Calling ioctl() to re-read partition table.

  WARNING: If you have created or modified any DOS 6.x

  partitions, please see the fdisk manual page for additional

  information.

  Syncing disks.

  [root@hk byrd]# mkfs -t ext4 /dev/sdb2

  mke2fs 1.41.12 (17-May-2010)

  文件系统标签=

  操作系统:Linux

  块大小=4096 (log=2)

  分块大小=4096 (log=2)

  Stride=0 blocks, Stripe width=0 blocks

  459648 inodes, 1837434 blocks

  91871 blocks (5.00%) reserved for the super user

  第一个数据块=0

  Maximum filesystem blocks=1883242496

  57 block groups

  32768 blocks per group, 32768 fragments per group

  8064 inodes per group

  Superblock backups stored on blocks:

  32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

  正在写入inode表: 完成

  Creating journal (32768 blocks): 完成

  Writing superblocks and filesystem accounting information: 完成

  This filesystem will be automatically checked every 32 mounts or

  180 days, whichever comes first. Use tune2fs -c or -i to override.

  [root@hk byrd]# mkfs -t ext4 /dev/sdb3

  mke2fs 1.41.12 (17-May-2010)

  mkfs.ext4: inode_size (128) * inodes_count (0) too big for a

  filesystem with 0 blocks, specify higher inode_ratio (-i)

  or lower inode count (-N).

  [root@hk byrd]# mkfs -t ext4 /dev/sdb3

  mke2fs 1.41.12 (17-May-2010)

  mkfs.ext4: inode_size (128) * inodes_count (0) too big for a

  filesystem with 0 blocks, specify higher inode_ratio (-i)

  or lower inode count (-N).

  [root@hk byrd]# fdisk /dev/sdb

  WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

  switch off the mode (command 'c') and change display units to

  sectors (command 'u').

  Command (m for help): d

  Partition number (1-5): 3

  Command (m for help): p

  Disk /dev/sdb: 16.1 GB, 16106127360 bytes

  255 heads, 63 sectors/track, 1958 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0xcbc85cc2

  Device Boot Start End Blocks Id System

  /dev/sdb1 1 132 1060258+ 8e Linux LVM

  /dev/sdb2 133 1047 7349737+ 8e Linux LVM

  Command (m for help): n

  Command action

  e extended

  p primary partition (1-4)

  p

  Partition number (1-4): 3

  First cylinder (1048-1958, default 1048):

  Using default value 1048

  Last cylinder, +cylinders or +size{K,M,G} (1048-1958, default 1958):

  Using default value 1958

  Command (m for help): p

  Disk /dev/sdb: 16.1 GB, 16106127360 bytes

  255 heads, 63 sectors/track, 1958 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0xcbc85cc2

  Device Boot Start End Blocks Id System

  /dev/sdb1 1 132 1060258+ 8e Linux LVM

  /dev/sdb2 133 1047 7349737+ 8e Linux LVM

  /dev/sdb3 1048 1958 7317607+ 83 Linux

  Command (m for help): w

  The partition table has been altered!

  Calling ioctl() to re-read partition table.

  Syncing disks.

  [root@hk byrd]# mkfs -t ext4 /dev/sdb3

  mke2fs 1.41.12 (17-May-2010)

  文件系统标签=

  操作系统:Linux

  块大小=4096 (log=2)

  分块大小=4096 (log=2)

  Stride=0 blocks, Stripe width=0 blocks

  457856 inodes, 1829401 blocks

  91470 blocks (5.00%) reserved for the super user

  第一个数据块=0

  Maximum filesystem blocks=1874853888

  56 block groups

  32768 blocks per group, 32768 fragments per group

  8176 inodes per group

  Superblock backups stored on blocks:

  32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

  正在写入inode表: 完成

  Creating journal (32768 blocks): 完成

  Writing superblocks and filesystem accounting information: 完成

  This filesystem will be automatically checked every 35 mounts or

  180 days, whichever comes first. Use tune2fs -c or -i to override.

  [root@hk byrd]# df -lh

  文件系统 容量 已用 可用 已用%% 挂载点

  /dev/mapper/vg_cloud-lv_root

  7.5G 3.5G 3.7G 49% /

  tmpfs 249M 0 249M 0% /dev/shm

  /dev/sda1 485M 32M 428M 7% /boot

  [root@hk byrd]# df

  文件系统 1K-块 已用 可用 已用% 挂载点

  /dev/mapper/vg_cloud-lv_root

  7781012 3590352 3795396 49% /

  tmpfs 254584 0 254584 0% /dev/shm

  /dev/sda1 495844 31980 438264 7% /boot

  [root@hk byrd]# fdisk -l

  Disk /dev/sda: 10.7 GB, 10737418240 bytes

  255 heads, 63 sectors/track, 1305 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00073ffb

  Device Boot Start End Blocks Id System

  /dev/sda1 * 1 64 512000 83 Linux

  Partition 1 does not end on cylinder boundary.

  /dev/sda2 64 1306 9972736 8e Linux LVM

  Disk /dev/sdb: 16.1 GB, 16106127360 bytes

  255 heads, 63 sectors/track, 1958 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0xcbc85cc2

  Device Boot Start End Blocks Id System

  /dev/sdb1 1 132 1060258+ 8e Linux LVM

  /dev/sdb2 133 1047 7349737+ 8e Linux LVM

  /dev/sdb3 1048 1958 7317607+ 83 Linux

  Disk /dev/mapper/vg_cloud-lv_root: 8095 MB, 8095006720 bytes

  255 heads, 63 sectors/track, 984 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00000000

  Disk /dev/mapper/vg_cloud-lv_swap: 2113 MB, 2113929216 bytes

  255 heads, 63 sectors/track, 257 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00000000

  [root@hk byrd]# fdisk /dev/sdb

  WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

  switch off the mode (command 'c') and change display units to

  sectors (command 'u').

  Command (m for help): t

  Partition number (1-4): 3

  Hex code (type L to list codes): 8e

  Changed system type of partition 3 to 8e (Linux LVM)

  Command (m for help): w

  The partition table has been altered!

  Calling ioctl() to re-read partition table.

  Syncing disks.

  [root@hk byrd]# mkfs -t ext4 /dev/sdb3

  mke2fs 1.41.12 (17-May-2010)

  文件系统标签=

  操作系统:Linux

  块大小=4096 (log=2)

  分块大小=4096 (log=2)

  Stride=0 blocks, Stripe width=0 blocks

  457856 inodes, 1829401 blocks

  91470 blocks (5.00%) reserved for the super user

  第一个数据块=0

  Maximum filesystem blocks=1874853888

  56 block groups

  32768 blocks per group, 32768 fragments per group

  8176 inodes per group

  Superblock backups stored on blocks:

  32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

  正在写入inode表: 完成

  Creating journal (32768 blocks): 完成

  Writing superblocks and filesystem accounting information: 完成

  This filesystem will be automatically checked every 28 mounts or

  180 days, whichever comes first. Use tune2fs -c or -i to override.

  [root@hk byrd]# fdisk -l

  Disk /dev/sda: 10.7 GB, 10737418240 bytes

  255 heads, 63 sectors/track, 1305 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00073ffb

  Device Boot Start End Blocks Id System

  /dev/sda1 * 1 64 512000 83 Linux

  Partition 1 does not end on cylinder boundary.

  /dev/sda2 64 1306 9972736 8e Linux LVM

  Disk /dev/sdb: 16.1 GB, 16106127360 bytes

  255 heads, 63 sectors/track, 1958 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0xcbc85cc2

  Device Boot Start End Blocks Id System

  /dev/sdb1 1 132 1060258+ 8e Linux LVM

  /dev/sdb2 133 1047 7349737+ 8e Linux LVM

  /dev/sdb3 1048 1958 7317607+ 8e Linux LVM

  Disk /dev/mapper/vg_cloud-lv_root: 8095 MB, 8095006720 bytes

  255 heads, 63 sectors/track, 984 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00000000

  Disk /dev/mapper/vg_cloud-lv_swap: 2113 MB, 2113929216 bytes

  255 heads, 63 sectors/track, 257 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00000000

  [root@hk byrd]# cd /dev/sda2

  bash: cd: /dev/sda2: 不是目录

  [root@hk byrd]# ll /dev/sda2

  brw-rw----. 1 root disk 8, 2 5月 5 22:01 /dev/sda2

  [root@hk byrd]# partprobe

  Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (设备或资源忙). As a result, it may not reflect all of your changes until after reboot.

  [root@hk byrd]# vgdisplay

  --- Volume group ---

  VG Name vg_cloud

  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 9.51 GiB

  PE Size 4.00 MiB

  Total PE 2434

  Alloc PE / Size 2434 / 9.51 GiB

  Free PE / Size 0 / 0

  VG UUID aCGg1q-jFG3-v3qC-1TY0-ELpR-o7o3-jxoZmz

  [root@hk byrd]# df

  文件系统 1K-块 已用 可用 已用% 挂载点

  /dev/mapper/vg_cloud-lv_root

  7781012 3590360 3795388 49% /

  tmpfs 254584 0 254584 0% /dev/shm

  /dev/sda1 495844 31980 438264 7% /boot

  [root@hk byrd]# free -m

  total used free shared buffers cached

  Mem: 497 187 309 0 2 122

  -/+ buffers/cache: 62 434

  Swap: 2015 0 2015

  [root@hk byrd]# fdisk -l

  Disk /dev/sda: 10.7 GB, 10737418240 bytes

  255 heads, 63 sectors/track, 1305 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00073ffb

  Device Boot Start End Blocks Id System

  /dev/sda1 * 1 64 512000 83 Linux

  Partition 1 does not end on cylinder boundary.

  /dev/sda2 64 1306 9972736 8e Linux LVM

  Disk /dev/sdb: 16.1 GB, 16106127360 bytes

  255 heads, 63 sectors/track, 1958 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0xcbc85cc2

  Device Boot Start End Blocks Id System

  /dev/sdb1 1 132 1060258+ 8e Linux LVM

  /dev/sdb2 133 1047 7349737+ 8e Linux LVM

  /dev/sdb3 1048 1958 7317607+ 8e Linux LVM

  Disk /dev/mapper/vg_cloud-lv_root: 8095 MB, 8095006720 bytes

  255 heads, 63 sectors/track, 984 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00000000

  Disk /dev/mapper/vg_cloud-lv_swap: 2113 MB, 2113929216 bytes

  255 heads, 63 sectors/track, 257 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00000000

  [root@hk byrd]# cat /etc/fstab

  #

  # /etc/fstab

  # Created by anaconda on Mon Apr 8 00:57:21 2013

  #

  # Accessible filesystems, by reference, are maintained under '/dev/disk'

  # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

  #

  /dev/mapper/vg_cloud-lv_root / ext4 defaults 1 1

  UUID=63f656e2-4a3c-4b34-a59e-13358830e87b /boot ext4 defaults 1 2

  /dev/mapper/vg_cloud-lv_swap swap swap defaults 0 0

  tmpfs /dev/shm tmpfs defaults 0 0

  devpts /dev/pts devpts gid=5,mode=620 0 0

  sysfs /sys sysfs defaults 0 0

  proc /proc proc defaults 0 0

  [root@hk byrd]# :q

  bash: :q: command not found

  [root@hk byrd]# swapo

  swapoff swapon

  [root@hk byrd]# swapoff

  Usage:

  swapoff -a [-v] disable all swaps

  swapoff [-v] <special> disable given swap

  swapoff -h display help

  swapoff -V display version

  The <special> parameter:

  {-L label | LABEL=label} LABEL of device to be used

  {-U uuid | UUID=uuid} UUID of device to be used

  <device> name of device to be used

  <file> name of file to be used

  [root@hk byrd]# swapoff a

  swapoff: a: swapoff failed: 没有那个文件或目录

  [root@hk byrd]# swapoff /dev/mapper/vg_cloud-lv_swap

  [root@hk byrd]# lvre

  lvreduce lvremove lvrename lvresize

  [root@hk byrd]# lvremove

  Please enter one or more logical volume paths

  Run `lvremove --help' for more information.

  [root@hk byrd]# lvremove --help

  lvremove: Remove logical volume(s) from the system

  lvremove

  [-A|--autobackup y|n]

  [-d|--debug]

  [-f|--force]

  [-h|--help]

  [--noudevsync]

  [-t|--test]

  [-v|--verbose]

  [--version]

  LogicalVolume[Path] [LogicalVolume[Path]...]

  [root@hk byrd]# lvremove /dev/mapper/vg_cloud-lv_swap

  Do you really want to remove active logical volume lv_swap? [y/n]: y

  Logical volume "lv_swap" successfully removed

  [root@hk byrd]# vgdisplay

  --- Volume group ---

  VG Name vg_cloud

  System ID

  Format lvm2

  Metadata Areas 1

  Metadata Sequence No 4

  VG Access read/write

  VG Status resizable

  MAX LV 0

  Cur LV 1

  Open LV 1

  Max PV 0

  Cur PV 1

  Act PV 1

  VG Size 9.51 GiB

  PE Size 4.00 MiB

  Total PE 2434

  Alloc PE / Size 1930 / 7.54 GiB

  Free PE / Size 504 / 1.97 GiB

  VG UUID aCGg1q-jFG3-v3qC-1TY0-ELpR-o7o3-jxoZmz

  [root@hk byrd]# lvextend -L 1.97G /dev/mapper/vg_cloud-lv_root

  Rounding size to boundary between physical extents: 1.97 GiB

  New size given (505 extents) not larger than existing size (1930 extents)

  Run `lvextend --help' for more information.

  [root@hk byrd]# lvextend -L 2G /dev/mapper/vg_cloud-lv_root

  New size given (512 extents) not larger than existing size (1930 extents)

  Run `lvextend --help' for more information.

  [root@hk byrd]# lvextend --help

  lvextend: Add space to a logical volume

  lvextend

  [-A|--autobackup y|n]

  [--alloc AllocationPolicy]

  [-d|--debug]

  [-f|--force]

  [-h|--help]

  [-i|--stripes Stripes [-I|--stripesize StripeSize]]

  {-l|--extents [+]LogicalExtentsNumber[%{VG|LV|PVS|FREE|ORIGIN}] |

  -L|--size [+]LogicalVolumeSize[bBsSkKmMgGtTpPeE]}

  [-m|--mirrors Mirrors]

  [--nosync]

  [--use-policies]

  [-n|--nofsck]

  [--noudevsync]

  [-r|--resizefs]

  [-t|--test]

  [--type VolumeType]

  [-v|--verbose]

  [--version]

  LogicalVolume[Path] [ PhysicalVolumePath... ]

  [root@hk byrd]# lvextend -L +100%FREE /dev/mapper/vg_cloud-lv_root

  Invalid argument for --size: +100%FREE

  Error during parsing of command line.

  [root@hk byrd]# lvextend -l +100%FREE /dev/mapper/vg_cloud-lv_root

  Extending logical volume lv_root to 9.51 GiB

  Logical volume lv_root successfully resized

  [root@hk byrd]# lvdisplay

  --- Logical volume ---

  LV Path /dev/vg_cloud/lv_root

  LV Name lv_root

  VG Name vg_cloud

  LV UUID KIAvQH-uqD9-CjNo-lyjd-Znq4-xyZf-9UBjF7

  LV Write Access read/write

  LV Creation host, time cloud, 2013-04-08 00:56:35 +0800

  LV Status available

  # open 1

  LV Size 9.51 GiB

  Current LE 2434

  Segments 1

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:0

  [root@hk byrd]# vgdisplay

  --- Volume group ---

  VG Name vg_cloud

  System ID

  Format lvm2

  Metadata Areas 1

  Metadata Sequence No 5

  VG Access read/write

  VG Status resizable

  MAX LV 0

  Cur LV 1

  Open LV 1

  Max PV 0

  Cur PV 1

  Act PV 1

  VG Size 9.51 GiB

  PE Size 4.00 MiB

  Total PE 2434

  Alloc PE / Size 2434 / 9.51 GiB

  Free PE / Size 0 / 0

  VG UUID aCGg1q-jFG3-v3qC-1TY0-ELpR-o7o3-jxoZmz

  [root@hk byrd]# df -h

  文件系统 容量 已用 可用 已用%% 挂载点

  /dev/mapper/vg_cloud-lv_root

  7.5G 3.5G 3.7G 49% /

  tmpfs 249M 0 249M 0% /dev/shm

  /dev/sda1 485M 32M 428M 7% /boot

  [root@hk byrd]# resize2fs /dev/mapper/vg_cloud-lv_root

  resize2fs 1.41.12 (17-May-2010)

  Filesystem at /dev/mapper/vg_cloud-lv_root is mounted on /; on-line resizing required

  old desc_blocks = 1, new_desc_blocks = 1

  Performing an on-line resize of /dev/mapper/vg_cloud-lv_root to 2492416 (4k) blocks.

  The filesystem on /dev/mapper/vg_cloud-lv_root is now 2492416 blocks long.

  [root@hk byrd]# df -h

  文件系统 容量 已用 可用 已用%% 挂载点

  /dev/mapper/vg_cloud-lv_root

  9.4G 3.5G 5.5G 39% /

  tmpfs 249M 0 249M 0% /dev/shm

  /dev/sda1 485M 32M 428M 7% /boot

  [root@hk byrd]# fdisk -l

  Disk /dev/sda: 10.7 GB, 10737418240 bytes

  255 heads, 63 sectors/track, 1305 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00073ffb

  Device Boot Start End Blocks Id System

  /dev/sda1 * 1 64 512000 83 Linux

  Partition 1 does not end on cylinder boundary.

  /dev/sda2 64 1306 9972736 8e Linux LVM

  Disk /dev/sdb: 16.1 GB, 16106127360 bytes

  255 heads, 63 sectors/track, 1958 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0xcbc85cc2

  Device Boot Start End Blocks Id System

  /dev/sdb1 1 132 1060258+ 8e Linux LVM

  /dev/sdb2 133 1047 7349737+ 8e Linux LVM

  /dev/sdb3 1048 1958 7317607+ 8e Linux LVM

  Disk /dev/mapper/vg_cloud-lv_root: 10.2 GB, 10208935936 bytes

  255 heads, 63 sectors/track, 1241 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00000000

  [root@hk byrd]# fdisk /dev/sdb

  WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

  switch off the mode (command 'c') and change display units to

  sectors (command 'u').

  Command (m for help): m^Hq^C

  [root@hk byrd]# gfdisk /dev/sdb

  bash: gfdisk: command not found

  [root@hk byrd]# cfdisk /dev/sdb

  Disk has been changed.

  WARNING: If you have created or modified any

  DOS 6.x partitions, please see the cfdisk manual

  page for additional information.

  [root@hk byrd]# fdisk -l

  Disk /dev/sda: 10.7 GB, 10737418240 bytes

  255 heads, 63 sectors/track, 1305 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00073ffb

  Device Boot Start End Blocks Id System

  /dev/sda1 * 1 64 512000 83 Linux

  Partition 1 does not end on cylinder boundary.

  /dev/sda2 64 1306 9972736 8e Linux LVM

  Disk /dev/sdb: 16.1 GB, 16106127360 bytes

  255 heads, 63 sectors/track, 1958 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0xcbc85cc2

  Device Boot Start End Blocks Id System

  /dev/sdb1 * 1 1959 15728608+ 8e Linux LVM

  Disk /dev/mapper/vg_cloud-lv_root: 10.2 GB, 10208935936 bytes

  255 heads, 63 sectors/track, 1241 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00000000

  [root@hk byrd]# pvcreate /dev/sdb1

  WARNING: swap signature detected on /dev/sdb1. Wipe it? [y/n] y

  Wiping swap signature on /dev/sdb1.

  Physical volume "/dev/sdb1" successfully created

  [root@hk byrd]# pvdisplay

  --- Physical volume ---

  PV Name /dev/sda2

  VG Name vg_cloud

  PV Size 9.51 GiB / not usable 3.00 MiB

  Allocatable yes (but full)

  PE Size 4.00 MiB

  Total PE 2434

  Free PE 0

  Allocated PE 2434

  PV UUID dtK0fn-wMNW-wB8L-ueXq-H3Ad-cek9-5wCgac

  "/dev/sdb1" is a new physical volume of "15.00 GiB"

  --- NEW Physical volume ---

  PV Name /dev/sdb1

  VG Name

  PV Size 15.00 GiB

  Allocatable NO

  PE Size 0

  Total PE 0

  Free PE 0

  Allocated PE 0

  PV UUID rb1M7k-g0HW-lHpb-rCbx-Uz5b-tXOn-2JEx52

  [root@hk byrd]# vgdisplay

  --- Volume group ---

  VG Name vg_cloud

  System ID

  Format lvm2

  Metadata Areas 1

  Metadata Sequence No 5

  VG Access read/write

  VG Status resizable

  MAX LV 0

  Cur LV 1

  Open LV 1

  Max PV 0

  Cur PV 1

  Act PV 1

  VG Size 9.51 GiB

  PE Size 4.00 MiB

  Total PE 2434

  Alloc PE / Size 2434 / 9.51 GiB

  Free PE / Size 0 / 0

  VG UUID aCGg1q-jFG3-v3qC-1TY0-ELpR-o7o3-jxoZmz

  [root@hk byrd]# vgextend vg_cloud /dev/sdb1

  Volume group "vg_cloud" successfully extended

  [root@hk byrd]# vgdisplay

  --- Volume group ---

  VG Name vg_cloud

  System ID

  Format lvm2

  Metadata Areas 2

  Metadata Sequence No 6

  VG Access read/write

  VG Status resizable

  MAX LV 0

  Cur LV 1

  Open LV 1

  Max PV 0

  Cur PV 2

  Act PV 2

  VG Size 24.50 GiB

  PE Size 4.00 MiB

  Total PE 6273

  Alloc PE / Size 2434 / 9.51 GiB

  Free PE / Size 3839 / 15.00 GiB

  VG UUID aCGg1q-jFG3-v3qC-1TY0-ELpR-o7o3-jxoZmz

  [root@hk byrd]# lvdisplay

  --- Logical volume ---

  LV Path /dev/vg_cloud/lv_root

  LV Name lv_root

  VG Name vg_cloud

  LV UUID KIAvQH-uqD9-CjNo-lyjd-Znq4-xyZf-9UBjF7

  LV Write Access read/write

  LV Creation host, time cloud, 2013-04-08 00:56:35 +0800

  LV Status available

  # open 1

  LV Size 9.51 GiB

  Current LE 2434

  Segments 1

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:0

  [root@hk byrd]# lvextend -l +14G /dev/mapper/vg_cloud-lv_root

  Invalid argument for --extents: +14G

  Error during parsing of command line.

  [root@hk byrd]# lvextend x--help

  Please specify either size or extents but not both.

  Run `lvextend --help' for more information.

  [root@hk byrd]# lvextend --help

  lvextend: Add space to a logical volume

  lvextend

  [-A|--autobackup y|n]

  [--alloc AllocationPolicy]

  [-d|--debug]

  [-f|--force]

  [-h|--help]

  [-i|--stripes Stripes [-I|--stripesize StripeSize]]

  {-l|--extents [+]LogicalExtentsNumber[%{VG|LV|PVS|FREE|ORIGIN}] |

  -L|--size [+]LogicalVolumeSize[bBsSkKmMgGtTpPeE]}

  [-m|--mirrors Mirrors]

  [--nosync]

  [--use-policies]

  [-n|--nofsck]

  [--noudevsync]

  [-r|--resizefs]

  [-t|--test]

  [--type VolumeType]

  [-v|--verbose]

  [--version]

  LogicalVolume[Path] [ PhysicalVolumePath... ]

  [root@hk byrd]# lvextend -L 14G /dev/mapper/vg_cloud-lv_root

  Extending logical volume lv_root to 14.00 GiB

  Logical volume lv_root successfully resized

  [root@hk byrd]# lvdisplay

  --- Logical volume ---

  LV Path /dev/vg_cloud/lv_root

  LV Name lv_root

  VG Name vg_cloud

  LV UUID KIAvQH-uqD9-CjNo-lyjd-Znq4-xyZf-9UBjF7

  LV Write Access read/write

  LV Creation host, time cloud, 2013-04-08 00:56:35 +0800

  LV Status available

  # open 1

  LV Size 14.00 GiB

  Current LE 3584

  Segments 2

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:0

  [root@hk byrd]# vgdisplay

  --- Volume group ---

  VG Name vg_cloud

  System ID

  Format lvm2

  Metadata Areas 2

  Metadata Sequence No 7

  VG Access read/write

  VG Status resizable

  MAX LV 0

  Cur LV 1

  Open LV 1

  Max PV 0

  Cur PV 2

  Act PV 2

  VG Size 24.50 GiB

  PE Size 4.00 MiB

  Total PE 6273

  Alloc PE / Size 3584 / 14.00 GiB

  Free PE / Size 2689 / 10.50 GiB

  VG UUID aCGg1q-jFG3-v3qC-1TY0-ELpR-o7o3-jxoZmz

  [root@hk byrd]# lvextend -L 23.5G /dev/mapper/vg_cloud-lv_root

  Extending logical volume lv_root to 23.50 GiB

  Logical volume lv_root successfully resized

  [root@hk byrd]# vgdisplay

  --- Volume group ---

  VG Name vg_cloud

  System ID

  Format lvm2

  Metadata Areas 2

  Metadata Sequence No 8

  VG Access read/write

  VG Status resizable

  MAX LV 0

  Cur LV 1

  Open LV 1

  Max PV 0

  Cur PV 2

  Act PV 2

  VG Size 24.50 GiB

  PE Size 4.00 MiB

  Total PE 6273

  Alloc PE / Size 6016 / 23.50 GiB

  Free PE / Size 257 / 1.00 GiB

  VG UUID aCGg1q-jFG3-v3qC-1TY0-ELpR-o7o3-jxoZmz

  [root@hk byrd]# lvdisplay

  --- Logical volume ---

  LV Path /dev/vg_cloud/lv_root

  LV Name lv_root

  VG Name vg_cloud

  LV UUID KIAvQH-uqD9-CjNo-lyjd-Znq4-xyZf-9UBjF7

  LV Write Access read/write

  LV Creation host, time cloud, 2013-04-08 00:56:35 +0800

  LV Status available

  # open 1

  LV Size 23.50 GiB

  Current LE 6016

  Segments 2

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:0

  [root@hk byrd]# lvcreate --help

  lvcreate: Create a logical volume

  lvcreate

  [-A|--autobackup {y|n}]

  [-a|--activate [a|e|l]{y|n}]

  [--addtag Tag]

  [--alloc AllocationPolicy]

  [-C|--contiguous {y|n}]

  [-d|--debug]

  [-h|-?|--help]

  [--ignoremonitoring]

  [--monitor {y|n}]

  [-i|--stripes Stripes [-I|--stripesize StripeSize]]

  {-l|--extents LogicalExtentsNumber[%{VG|PVS|FREE}] |

  -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}

  [-M|--persistent {y|n}] [--major major] [--minor minor]

  [-m|--mirrors Mirrors [--nosync] [{--mirrorlog {disk|core|mirrored}|--corelog}]]

  [-n|--name LogicalVolumeName]

  [--noudevsync]

  [-p|--permission {r|rw}]

  [-r|--readahead ReadAheadSectors|auto|none]

  [-R|--regionsize MirrorLogRegionSize]

  [-T|--thin [-c|--chunksize ChunkSize]

  [--discards {ignore|nopassdown|passdown}]

  [--poolmetadatasize MetadataSize[bBsSkKmMgG]]]

  [--thinpool ThinPoolLogicalVolume{Name|Path}]

  [-t|--test]

  [--type VolumeType]

  [-v|--verbose]

  [-Z|--zero {y|n}]

  [--version]

  VolumeGroupName [PhysicalVolumePath...]

  lvcreate

  { {-s|--snapshot} OriginalLogicalVolume[Path] |

  [-s|--snapshot] VolumeGroupName[Path] -V|--virtualsize VirtualSize}

  {-T|--thin} VolumeGroupName[Path][/PoolLogicalVolume]

  -V|--virtualsize VirtualSize}

  [-c|--chunksize]

  [-A|--autobackup {y|n}]

  [--addtag Tag]

  [--alloc AllocationPolicy]

  [-C|--contiguous {y|n}]

  [-d|--debug]

  [--discards {ignore|nopassdown|passdown}]

  [-h|-?|--help]

  [--ignoremonitoring]

  [--monitor {y|n}]

  [-i|--stripes Stripes [-I|--stripesize StripeSize]]

  {-l|--extents LogicalExtentsNumber[%{VG|FREE|ORIGIN}] |

  -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}

  [--poolmetadatasize Size[bBsSkKmMgG]]

  [-M|--persistent {y|n}] [--major major] [--minor minor]

  [-n|--name LogicalVolumeName]

  [--noudevsync]

  [-p|--permission {r|rw}]

  [-r|--readahead ReadAheadSectors|auto|none]

  [-t|--test]

  [--thinpool ThinPoolLogicalVolume[Path]]

  [-v|--verbose]

  [--version]

  [PhysicalVolumePath...]

  [root@hk byrd]# lvcreate -l +100%FREE -Cy vg_cloud lv_swap

  Physical Volume "lv_swap" not found in Volume Group "vg_cloud"

  [root@hk byrd]# lvcreate -l +100%FREE -Cy vg_cloud -n lv_swap

  Logical volume "lv_swap" created

  [root@hk byrd]# lvdisplay

  --- Logical volume ---

  LV Path /dev/vg_cloud/lv_root

  LV Name lv_root

  VG Name vg_cloud

  LV UUID KIAvQH-uqD9-CjNo-lyjd-Znq4-xyZf-9UBjF7

  LV Write Access read/write

  LV Creation host, time cloud, 2013-04-08 00:56:35 +0800

  LV Status available

  # open 1

  LV Size 23.50 GiB

  Current LE 6016

  Segments 2

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:0

  --- Logical volume ---

  LV Path /dev/vg_cloud/lv_swap

  LV Name lv_swap

  VG Name vg_cloud

  LV UUID eLmu4B-2g3P-bM90-b0wO-UJyW-LNF1-N3Wl2l

  LV Write Access read/write

  LV Creation host, time hk.t4x.org, 2014-05-05 22:44:40 +0800

  LV Status available

  # open 0

  LV Size 1.00 GiB

  Current LE 257

  Segments 1

  Allocation contiguous

  Read ahead sectors auto

  - currently set to 256

  Block device 253:1

  [root@hk byrd]# vgdisplay

  --- Volume group ---

  VG Name vg_cloud

  System ID

  Format lvm2

  Metadata Areas 2

  Metadata Sequence No 9

  VG Access read/write

  VG Status resizable

  MAX LV 0

  Cur LV 2

  Open LV 1

  Max PV 0

  Cur PV 2

  Act PV 2

  VG Size 24.50 GiB

  PE Size 4.00 MiB

  Total PE 6273

  Alloc PE / Size 6273 / 24.50 GiB

  Free PE / Size 0 / 0

  VG UUID aCGg1q-jFG3-v3qC-1TY0-ELpR-o7o3-jxoZmz

  [root@hk byrd]# vim /etc/fstab

  [root@hk byrd]# swapon /dev/mapper/vg_cloud-lv_swap

  swapon: /dev/mapper/vg_cloud-lv_swap: read swap header failed: 无效的参数

  [root@hk byrd]# mkswap /dev/mapper/vg_cloud-lv_swap

  mkswap: /dev/mapper/vg_cloud-lv_swap: warning: don't erase bootbits sectors

  on whole disk. Use -f to force.

  Setting up swapspace version 1, size = 1052668 KiB

  no label, UUID=9664825a-ab76-488f-b7f3-fa95159dbaa1

  [root@hk byrd]# swapon /dev/mapper/vg_cloud-lv_swap

  [root@hk byrd]# free -m

  total used free shared buffers cached

  Mem: 497 196 301 0 7 126

  -/+ buffers/cache: 62 435

  Swap: 1027 0 1027

  [root@hk byrd]# df -h

  文件系统 容量 已用 可用 已用%% 挂载点

  /dev/mapper/vg_cloud-lv_root

  9.4G 3.5G 5.5G 39% /

  tmpfs 249M 0 249M 0% /dev/shm

  /dev/sda1 485M 32M 428M 7% /boot

  [root@hk byrd]# free -m

  total used free shared buffers cached

  Mem: 497 196 301 0 7 126

  -/+ buffers/cache: 62 435

  Swap: 1027 0 1027

  [root@hk byrd]# resize2fs /dev/mapper/vg_cloud-lv_root

  resize2fs 1.41.12 (17-May-2010)

  Filesystem at /dev/mapper/vg_cloud-lv_root is mounted on /; on-line resizing required

  old desc_blocks = 1, new_desc_blocks = 2

  Performing an on-line resize of /dev/mapper/vg_cloud-lv_root to 6160384 (4k) blocks.

  The filesystem on /dev/mapper/vg_cloud-lv_root is now 6160384 blocks long.

  [root@hk byrd]# df -h\

  > ^C

  [root@hk byrd]# df -h

  文件系统 容量 已用 可用 已用%% 挂载点

  /dev/mapper/vg_cloud-lv_root

  24G 3.5G 19G 16% /

  tmpfs 249M 0 249M 0% /dev/shm

  /dev/sda1 485M 32M 428M 7% /boot

  [root@hk byrd]# free -m

  total used free shared buffers cached

  Mem: 497 200 296 0 11 126

  -/+ buffers/cache: 62 434

  Swap: 1027 0 1027

  [root@hk byrd]# watch -n 1 -d date

  [root@hk byrd]#

« 上一篇 下一篇 » admin原创文章,转载请注明出处! 标签:linux设置linux优化linux分区

相关日志:

«   2019年11月   »
123
45678910
11121314151617
18192021222324
252627282930
控制面板
您好,欢迎到访网站!
  [查看权限]
网站分类
文章归档
网站收藏
友情链接
图标汇集
  • 又拍云
  • 订阅ipvb的RSS 2.0聚合