linux磁盘分区和挂载

来源:互联网 发布:mac系统照片图库打不开 编辑:程序博客网 时间:2024/05/21 09:23
查看磁盘使用情况
[root@monitorZ195f02f8Zd013Z4c49Zb4Z cloud_logs]# df -lh
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1             97G   80G   13G  87% /
tmpfs                 2.0G   68K  2.0G   1% /dev/shm


查看分区
[root@monitorZ195f02f8Zd013Z4c49Zb4Z xray-collector]# fdisk -l


Disk /dev/xvda: 107.3 GB, 107374182400 bytes
224 heads, 56 sectors/track, 16718 cylinders
Units = cylinders of 12544 * 512 = 6422528 bytes


    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1       16718   104855268   83  Linux


Disk /dev/xvdc: 0 MB, 370688 bytes
224 heads, 56 sectors/track, 0 cylinders
Units = cylinders of 12544 * 512 = 6422528 bytes


Disk /dev/xvdc doesn't contain a valid partition table


Disk /dev/xvdb: 536.8 GB, 536870912000 bytes
224 heads, 56 sectors/track, 83591 cylinders
Units = cylinders of 12544 * 512 = 6422528 bytes


Disk /dev/xvdb doesn't contain a valid partition table


对/dev/xvdb分区
[root@monitorZ195f02f8Zd013Z4c49Zb4Z xray-collector]# fdisk /dev/xvdb
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 83591.
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)


使用m命令查看所有的命令项
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/xvdb: 536.8 GB, 536870912000 bytes
224 heads, 56 sectors/track, 83591 cylinders
Units = cylinders of 12544 * 512 = 6422528 bytes


    Device Boot      Start         End      Blocks   Id  System


创建新分区
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-83591, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-83591, default 83591): 
Using default value 83591


Command (m for help): p


Disk /dev/xvdb: 536.8 GB, 536870912000 bytes
224 heads, 56 sectors/track, 83591 cylinders
Units = cylinders of 12544 * 512 = 6422528 bytes


    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1               1       83591   524282724    5  Extended


创建逻辑分区
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (1-83591, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-83591, default 83591): 
Using default value 83591


Command (m for help): p


Disk /dev/xvdb: 536.8 GB, 536870912000 bytes
224 heads, 56 sectors/track, 83591 cylinders
Units = cylinders of 12544 * 512 = 6422528 bytes


    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1               1       83591   524282724    5  Extended
/dev/xvdb5               1       83591   524282696   83  Linux


Command (m for help): w
The partition table has been altered!


Calling ioctl() to re-read partition table.
Syncing disks.
[root@monitorZ195f02f8Zd013Z4c49Zb4Z xray-collector]# df -lh
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1             97G   80G   12G  87% /
tmpfs                 2.0G   68K  2.0G   1% /dev/shm


对/dev/xvdb进行格式化,采用ext3
[root@monitorZ195f02f8Zd013Z4c49Zb4Z xray-collector]# mkfs.ext3 /dev/xvdb5
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
65536000 inodes, 131070674 blocks
6553533 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
4000 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


Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done


This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.


创建挂载点
[root@monitorZ195f02f8Zd013Z4c49Zb4Z xray-collector]# mkdir /data


修改fstab文件
[root@monitorZ195f02f8Zd013Z4c49Zb4Z xray-collector]# vi /etc/fstab
增加:
/dev/xvdb5              /data                   ext3    defaults        0 0


挂载/dev/xvdb5到/data
[root@monitorZ195f02f8Zd013Z4c49Zb4Z xray-collector]# mount /dev/xvdb5 /data


[root@monitorZ195f02f8Zd013Z4c49Zb4Z xray-collector]# df -lh
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1             97G   81G   12G  88% /
tmpfs                 2.0G   68K  2.0G   1% /dev/shm
/dev/xvdb5            493G  198M  467G   1% /data
0 0
原创粉丝点击