创建、修改、挂载磁盘

使用fdisk 创建小于2T的磁盘分区

-CU  为柱面分区并关闭DOS检测模式

[root@web01 ~]# fdisk -cu /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x6df1fa98.
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)


Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First sector (2048-208895, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-208895, default 208895): Using default value 208895 Command (m for help): p Disk /dev/sdc: 106 MB, 106954752 bytes 64 heads, 32 sectors/track, 102 cylinders, total 208896 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x6df1fa98 Device Boot Start End Blocks Id System /dev/sdc1 2048 208895 103424 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.

更新磁盘分区表并格式化分区

[root@web01 ~]# partprobe /dev/sdc1
[root@web01 ~]# mkfs.ext4 /dev/sdc1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
25896 inodes, 103424 blocks
5171 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
13 block groups
8192 blocks per group, 8192 fragments per group
1992 inodes per group
Superblock backups stored on blocks: 
    8193, 24577, 40961, 57345, 73729

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

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

修改非系统磁盘的检测功能

[root@web01 ~]# tune2fs -c 0 -i 0 /dev/sdc1
tune2fs 1.41.12 (17-May-2010)
Setting maximal mount count to -1
Setting interval between checks to 0 seconds

进行磁盘挂载操作(临时)

[root@web01 ~]# mount /dev/sdc1 /data/
[root@web01 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3       8.6G  2.2G  6.0G  27% /
tmpfs           1.9G     0  1.9G   0% /dev/shm
/dev/sda1       190M   40M  141M  22% /boot
/dev/sdb1        94M  1.6M   88M   2% /data01
/dev/sdc1        94M  1.6M   88M   2% /data

永久挂载

[root@web01 ~]# vim /etc/fstab 
/dev/sdc1        /data            ext4    defaults    0 0        
/tmp/500m swap swap defaults 0 0

创建临时SWAP并挂载方法:

 先创建想要的swap大小的文件并格式化成SWAP 文件

[root@web01 ~]# dd if=/dev/zero of=/tmp/50M bs=5M count=10
10+0 records in
10+0 records out
52428800 bytes (52 MB) copied, 1.60872 s, 32.6 MB/s
[root@web01 ~]# ls -hl /tmp
total 551M
-rw-r--r--. 1 root root 500M Mar 11 23:06 500m
-rw-r--r--. 1 root root  50M Mar 16 15:27 50M
drwxr-xr-x. 8 root root 4.0K Feb 18 10:18 etc

[root@web01 ~]# mkswap /tmp/50M mkswap: /tmp/50M: warning: don't erase bootbits sectors on whole disk. Use -f to force. Setting up swapspace version 1, size = 51196 KiB no label, UUID=09421fee-e811-41b4-b2d3-c9a9640360a1

进行挂载操作可分为临时与永久

[root@web01 ~]# swapon /tmp/50M
[root@web01 ~]# free
             total       used       free     shared    buffers     cached
Mem:       3908500     311092    3597408        208      27396     112084
-/+ buffers/cache:     171612    3736888
Swap:      1611764          0    1611764

 

posted @ 2019-04-03 05:48  小咔嚓  阅读(234)  评论(0编辑  收藏  举报