fdisk分区格式化
fdisk 扩展分区的时候,需要添加逻辑分区,然后用mkfs对逻辑分区格式化。
# fdisk /dev/sdd
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
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (1-121601, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-121601, default 121601):
Using default value 121601
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
====
对新建分区(例:/dev/sda1)进行格式化:mkfs.ext4 /dev/sdb1
把/dev/sdb1格式化成ext4文件系统。
# mkfs -t ext4 /dev/sdb1
===========
[root@ ~]# mkfs -t ext4 /dev/sda5
mke2fs 1.41.12 (17-May-2010)
/dev/sda5 alignment is offset by 512 bytes.
This may result in very poor performance, (re)-partitioning suggested.
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=1 blocks, Stripe width=0 blocks
54255616 inodes, 217002544 blocks
10850127 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
6623 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, 71663616, 78675968,
102400000, 214990848
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information
完成
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
=========================================
无法对 /dev/sda5 进行 stat 调用 --- 没有那个文件或目录
http://173.194.138.103/#newwindow=1&q=%E6%97%A0%E6%B3%95%E5%AF%B9+%2Fdev%2Fsda5+%E8%BF%9B%E8%A1%8C+stat+%E8%B0%83%E7%94%A8+---+%E6%B2%A1%E6%9C%89%E9%82%A3%E4%B8%AA%E6%96%87%E4%BB%B6%E6%88%96%E7%9B%AE%E5%BD%95
http://tieba.baidu.com/p/2485605827
刚划的分区要partprobe一下
http://linux.it.net.cn/CentOS/fast/2014/0806/3473.html
(1)主分区和扩展分区最多可以有4个(硬盘限制)。(2)扩展分区最多只能有一个(操作系统限制)(3)逻辑分区是由扩展分区持续分出来的分区。(4)能够被格式化后作为数据访问的分区为主要分区与逻辑分区,扩展分区无法格式化。(5)逻辑分区的数量依操作系统而不同,在linux系统中,IDE硬盘最多有59个逻辑分区(5号到63号),SATA硬盘则有11个逻辑分区(5号到15号)。
使用Centos分区工具fdisk来分区
在centos系统中,fdisk工具默认是安装过的。使用fdisk分区工具,有一个缺点就是,fdisk没有办法处理大于2TB以上的磁盘分区。这个需要特别注意。当然大于2TB以上的可以使用parted工具。
使用fdisk工具时,不需要去记命令,只要是用m就能看到所有的操作。使用fdisk不管你进行了什么操作,只要离开fdisk时按下“q”,那么所有的操作都不会生效!相反,按下“w”就是操作生效的意思。所以可以随便玩fdisk,记得离开时要是用“q”哦。
无法对 /dev/sda7 进行 stat 调用 — 没有那个文件或目录
The device apparently does not exist; did you specify it correctly?
啊!这个是什么东东,我在推出fdisk的时候已经保存过了,怎么还会出现这个呢!!!
注意:当你格式化的时候,提示没有找到文件什么的,就需要重启电脑了哦!若不想重启电脑就可以使用partprobe这个命令,来强制让内核重新找一次分区表。如果使用了这个命令,还提示要重启电脑的话,那就只有乖乖的重启了。
==========
http://blog.csdn.net/reage11/article/details/9059613
剩下的做为扩展分区
在扩展分区中划分一个作为逻辑分区
查看分区信息
保存分区信息
=========================
http://www.bijimi.com/other/os/28424.html
今天帮别人troubleshooting,给/dev/sda添加分区sda4之后,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).
把新添假的分区sda4删除,
再执行命令
fdisk /dev/sda //执行添加分区指令
partx -a /dev/sda //这一步就发现新添加的分区/dev/sda4已经在内核中有记录了,当时也没注意.
mkfs.ext4 /dev/sda4
还是报错.
突然想起:partx -a /dev/sda 原来的/dev/sda4已经在内核中有记录了.
于是乎就执行partx -d /dev/sda 将/dev/sda4的记录删掉.(直接partx -d /dev/sda4出错)
再执行partx -a /dev/sda (此时/dev/sda4就没有出现)
再进行格式化,就OK了.
以上为原创,转载请注明出处...
http://piaoyun.cc/centos-fdisk-mount.html
添加新硬盘后添加为扩展分区,格式化时候经常会遇到这个错误,
|
1
|
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)
|
原因是扩展分区不能直接格式化,智能格式化主分区和扩展分区,所以还需在这个扩展分区上继续添加一个逻辑分区,然后格式化
|
1
|
fdisk /dev/sdb
|
第一次执行这个命令的时候提示添加扩展分区,还需在执行一次 会提示逻辑分区和主分区,选择逻辑分区,然后再格式化为你需要的文件系统就ok了
上面的是添加的主分区步骤方法,扩展分区的区别在第一次执行fdisk /dev/sdb 选择 e, 之后要多执行一次 fdisk /dev/sdb 然后选择 l (L,是字母,不是数字!)
===================================
http://173.194.138.103/#q=mkfs.ext4++inodes_count+(0)+too+big+for+a&lr=lang_zh-CN%7Clang_zh-TW&newwindow=1&tbs=lr:lang_1zh-CN%7Clang_1zh-TW&tbas=0
============================
http://sonice.blog.51cto.com/994545/608859
下面介绍怎样将一块新硬盘分区、格式化、挂载到系统,如适合你请继续阅读。服务器上已经有两块硬盘,所以硬盘为sdc,后面就不做说明了,至于不知道sdc怎么回事的人,先去问问百度大哥再回来接着看。 公司内网的服务器硬盘空间不足,将新买来的150G硬盘挂载并设置成samba的共享目录,关于samba请参考此文章
Disk /dev/sdc: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 182401.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
h: unknown command
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 action
e extended
p primary partition (1-4)
p 输入p为主分区,e为逻辑分区
Partition number (1-4): 1 由于是新盘我们输入1来分第一个主分区,共可以分4个主分区
First cylinder (1-182401, default 1): 选择该分区的起始磁盘数,如无特殊需求强烈建议选择默认,也就是1来分区(直接按回车)
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-182401, default 182401): 定义该分区的大小,如果按默认(按回车)即是使用全部可用存储额,如分一个1G的空间,输入+1024m
Using default value 182401
The partition table has been altered!
Syncing disks.
Disk /dev/sdc: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
/dev/sdc1 1 182401 1465136001 83 Linux
我们可以对硬盘进行分区操作,前提是您把fdisk -l 弄明白了;通过fdisk -l ,我们能找出机器中所有硬盘个数及设备名称;比如上面的例子,我们会看到两个设备一个是/dev/hda ,另一个是/dev/sda ;
fdisk 操作硬盘的命令格式如下:
[root@localhost beinan]# fdisk 设备
比如我们通过 fdisk -l 得知 /dev/hda 或者 /dev/sda设备;我们如果想再添加或者删除一些分区,可以用
[root@localhost beinan]# fdisk /dev/hda
或
[root@localhost beinan]# fdisk /dev/sda
注 在以后的例子中,我们要以 /dev/sda设备为例,来讲解如何用fdisk 来操作添加、删除分区等动作;
1、fdisk 的说明;
当我们通过 fdisk 设备,进入相应设备的操作时,会发现有如下的提示;以 fdisk /dev/sda 设备为例,以下同;
[root@localhost beinan]# fdisk /dev/sda
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 注:l是列出分区类型,以供我们设置相应分区的类型;
m print this menu 注:m 是列出帮助信息;
n add a new partition 注:添加一个分区;
o create a new empty DOS partition table
p print the partition table 注:p列出分区表;
q quit without saving changes 注:不保存退出;
s create a new empty Sun disklabel
t change a partition's system id 注:t 改变分区类型;
u change display/entry units
v verify the partition table
w write table to disk and exit 注:把分区表写入硬盘并退出;
x extra functionality (experts only) 注:扩展应用,专家功能;
其实我们常用的只有注有中文的,其它的功能我们不常用(呵,主要是我不会用,否则早会卖弄一下了);x扩展功能,也不是常用的;一般的情况下只要懂得 d l m p q t w 就行了;
下面以实例操作来详述,没有例子没有办法就,新手也看不懂;
2、列出当前操作硬盘的分区情况,用p
Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
3、通过fdisk的d指令来删除一个分区
Command (m for help): p 注:列出分区情况;
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
Command (m for help): d 注:执行删除分区指定;
Partition number (1-6): 6 注:我想删除 sda6 ,就在这里输入 6 ;
Command (m for help): p 注:再查看一下硬盘分区情况,看是否删除了?
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
Command (m for help):
警告:删除分区时要小心,请看好分区的序号,如果您删除了扩展分区,扩展分区之下的逻辑分区都会删除;所以操作时一定要小心;如果知道自己操作错了,请不要惊慌,用q不保存退出;切记切记!!!!在分区操作错了之时,千万不要输入w保存退出!!!
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
183156736 inodes, 366284000 blocks
18314200 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
11179 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
180 days, whichever comes first. Use tune2fs -c or -i to override.
5、# mkdir /var/samba 新建挂载目录
7、# df -hl 查看分区大小是否和我们预定的一样:
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda7 9.5G 3.2G 5.9G 35% /
/dev/sda6 9.5G 151M 8.9G 2% /tmp
/dev/sda5 19G 3.6G 15G 20% /usr
/dev/sda3 19G 719M 18G 4% /home
/dev/sda2 230G 23G 196G 11% /var
/dev/sda1 99M 25M 69M 27% /boot
/dev/sdb1 233G 156G 78G 67% /var/samba2
tmpfs 1008M 0 1008M 0% /dev/shm
/dev/sdc1 1.4T 198M 1.3T 1% /var/samba 此行为新硬盘
8、# vi /etc/fstab 设置系统自动挂载硬盘,加入一行:
/dev/sdc1 /var/samba2 ext3 defaults 0 0
Centos6.4 磁盘分区实战篇
vps数据盘、系统盘分区操作:
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]#

浙公网安备 33010602011771号