Linux文件系统的管理



1、查看分区情况

[root@rhel63-9 ~]# fdisk -l

 

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes

255 heads, 63 sectors/track, 121601 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: 0x000ad0c8

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1       12749   102400000   83  Linux

/dev/sda2           12749       15298    20480000   82  Linux swap / Solaris

/dev/sda3           15298      121601   853879008+  83  Linux

 

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes

255 heads, 63 sectors/track, 121601 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

2、创建分区

[root@rhel63-9 ~]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x73c64f67.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

 

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

 

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

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): p  

 

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes

255 heads, 63 sectors/track, 121601 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: 0x73c64f67

 

   Device Boot      Start         End      Blocks   Id  System

 

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

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.

[root@rhel63-9 ~]# partprobe

Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.

[root@rhel63-9 ~]# sync;

[root@rhel63-9 ~]# reboot

3、创建PV

[root@rhel63-9 ~]# fdisk -l

 

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes

255 heads, 63 sectors/track, 121601 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: 0x73c64f67

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1      121601   976760001   83  Linux

 

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes

255 heads, 63 sectors/track, 121601 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: 0x000ad0c8

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1       12749   102400000   83  Linux

/dev/sda2           12749       15298    20480000   82  Linux swap / Solaris

/dev/sda3           15298      121601   853879008+  83  Linux

 

[root@rhel63-9 ~]# pvdisplay

  "/dev/sda3" is a new physical volume of "814.32 GiB"

  --- NEW Physical volume ---

  PV Name               /dev/sda3

  VG Name              

  PV Size               814.32 GiB

  Allocatable           NO

  PE Size               0  

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               v0hWNX-j0pA-ISds-edVp-n7Fj-8LlV-UujcDF

 

[root@rhel63-9 ~]# pvremove /dev/sda3

  Labels on physical volume "/dev/sda3" successfully wiped

[root@rhel63-9 ~]# pvdisplay

[root@rhel63-9 ~]# pvcreate /dev/sda3 /dev/sdb1

  Writing physical volume data to disk "/dev/sda3"

  Physical volume "/dev/sda3" successfully created

  Writing physical volume data to disk "/dev/sdb1"

  Physical volume "/dev/sdb1" successfully created

[root@rhel63-9 ~]# pvdisplay

  "/dev/sda3" is a new physical volume of "814.32 GiB"

  --- NEW Physical volume ---

  PV Name               /dev/sda3

  VG Name              

  PV Size               814.32 GiB

  Allocatable           NO

  PE Size               0  

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               8BcbtW-cjs9-koIY-GUSy-osAr-hpmJ-rKSvW9

  

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

  --- NEW Physical volume ---

  PV Name               /dev/sdb1

  VG Name              

  PV Size               931.51 GiB

  Allocatable           NO

  PE Size               0  

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               GMJOhb-m111-928y-xgrv-eXZO-cr37-37N5NC

4、创建VG

[root@rhel63-9 ~]# vgcreate VolGroup00 /dev/sda3 /dev/sdb1

  Volume group "VolGroup00" successfully created

[root@rhel63-9 ~]# vgdisplay

  --- Volume group ---

  VG Name               VolGroup00

  System ID            

  Format                lvm2

  Metadata Areas        2

  Metadata Sequence No  1

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                0

  Open LV               0

  Max PV                0

  Cur PV                2

  Act PV                2

  VG Size               1.70 TiB

  PE Size               4.00 MiB

  Total PE              446932

  Alloc PE / Size       0 / 0  

  Free  PE / Size       446932 / 1.70 TiB

  VG UUID               rB3Xcm-ZSw0-ekXe-WEH0-lgHe-sNOb-ZobRm0

5、创建LV

[root@rhel63-9 ~]# lvcreate -L 1.70T -n LogVol00 VolGroup00

  Rounding up size to full physical extent 1.70 TiB

  Logical volume "LogVol00" created

[root@rhel63-9 ~]# lvdisplay

  --- Logical volume ---

  LV Path                /dev/VolGroup00/LogVol00

  LV Name                LogVol00

  VG Name                VolGroup00

  LV UUID                bi7dmO-hRMt-00OO-ZL80-0Xax-6ol3-ieFilX

  LV Write Access        read/write

  LV Creation host, time rhel63-9, 2013-07-04 09:11:11 +0800

  LV Status              available

  # open                 0

  LV Size                1.70 TiB

  Current LE             445645

  Segments               2

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:0

6、格式化LV

[root@rhel63-9 ~]# mkfs.ext4 /dev/VolGroup00/LogVol00

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

114089984 inodes, 456340480 blocks

22817024 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

13927 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

 

Writing inode tables: done                            

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information:

done

 

This filesystem will be automatically checked every 38 mounts or

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

7、挂载LV

[root@rhel63-9 ~]# cd /

 [root@rhel63-9 /]# mkdir data

[root@rhel63-9 /]# mount /dev/VolGroup00/LogVol00 /data

[root@rhel63-9 /]# df -kh

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda1              97G   96G     0 100% /

tmpfs                  64G     0   64G   0% /dev/shm

/dev/mapper/VolGroup00-LogVol00

                      1.7T  196M  1.6T   1% /data

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值