4.5/4.6 磁盤格式化node
4.7/4.8 磁盤掛載linux
4.9 手動增長swap空間安全
4.5/4.6 磁盤格式化ide
#查看Linux所支持的文件格式spa
[root@zgxlinux-01 ~]# cat /etc/filesystems xfs ext4 ext3 ext2 nodev proc nodev devpts iso9660 vfat hfs hfsplus *
#格式化命令:mke2fs (不能指定爲xfs格式) mkfs (格式沒有限制)3d
選項 mke2fs -t #指定密鑰格式化成什麼文件系統 例如:ext4 /ext3 /ext2orm
mke2fs -b #指定塊大小ip
mke2fs -m #指定預留空間大小ci
mke2fs -i #指定inodeit
[root@zgxlinux-01 ~]# ls -l 總用量 8 -rw-r--r--. 1 root root 0 9月 5 14:24 1.txt -rwx------. 1 root root 2557 9月 4 13:07 anaconda-ks.cfg -rw-r--r--. 1 root root 32 9月 13 14:27 nhy -rw-r--r--. 1 root root 0 9月 13 14:43 user1 [root@zgxlinux-01 ~]# echo 1 >1.txt [root@zgxlinux-01 ~]# ls -l 1.txt -rw-r--r--. 1 root root 2 9月 17 14:59 1.txt [root@zgxlinux-01 ~]# du -sb 1.txt #按大小顯示 2 1.txt [root@zgxlinux-01 ~]# du -sh 1.txt #按塊顯示,不足4字節按1個塊4字節顯示 4.0K 1.txt
#格式化dev/sdb1指定爲ext4格式,同時指定塊大小爲4096
[root@zgxlinux-01 ~]# mke2fs -t ext4 -b 4096 /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) 文件系統標籤= OS type: Linux 塊大小=4096 (log=2) 分塊大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 262144 inodes, 1048576 blocks 52428 blocks (5.00%) reserved for the super user 第一個數據塊=0 Maximum filesystem blocks=1073741824 32 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 Allocating group tables: 完成 正在寫入inode表: 完成 Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 #還能夠用另外一個命令方式格式化 [root@zgxlinux-01 ~]# mkfs.ext4 /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) 文件系統標籤= OS type: Linux 塊大小=4096 (log=2) 分塊大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 262144 inodes, 1048576 blocks 52428 blocks (5.00%) reserved for the super user #表示給root用戶的預留空間 第一個數據塊=0 Maximum filesystem blocks=1073741824 32 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 Allocating group tables: 完成 正在寫入inode表: 完成 Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成
#格式化sdb2同時指定格式爲xfs格式
[root@zgxlinux-01 ~]# mkfs.xfs /dev/sdb2 meta-data=/dev/sdb2 isize=512 agcount=4, agsize=262144 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=1048576, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
#blkid命令查看還未掛載的磁盤命令
[root@zgxlinux-01 ~]# blkid /dev/sdb1 /dev/sdb1: UUID="821b4504-7879-48b9-a62c-0af55a27d25e" TYPE="ext4" [root@zgxlinux-01 ~]# blkid /dev/sdb2 /dev/sdb2: UUID="053fc287-462d-4f6c-acbf-2e95ee8c25b2" TYPE="xfs"
#格式化/dev/sdb3 ,同時指定格式爲ext4 ,塊大小2048 ,預留空間爲0.1%
[root@zgxlinux-01 ~]# mke2fs -t ext4 -b 2048 -m 0.1 /dev/sdb3 mke2fs 1.42.9 (28-Dec-2013) 文件系統標籤= OS type: Linux 塊大小=2048 (log=1) 分塊大小=2048 (log=1) Stride=0 blocks, Stripe width=0 blocks 262144 inodes, 2097152 blocks 2097 blocks (0.10%) reserved for the super user 第一個數據塊=0 Maximum filesystem blocks=270532608 128 block groups 16384 blocks per group, 16384 fragments per group 2048 inodes per group Superblock backups stored on blocks: 16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816, 1327104, 2048000 Allocating group tables: 完成 正在寫入inode表: 完成 Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成
#選項 :mount -o rw 可讀可寫 ro 只讀 renount 從新掛載
[user2@zgxlinux-01 ~]$ vi /etc/fstab #系統啓動默認掛載磁盤和分區的配置文件 UUID=7d46e9e9-a01b-4bca-9904-11fbf733c8a8 / xfs defaults 0 0 #根分區要檢測設置1 ,其餘分區要檢測設2,不檢測設 UUID=5f65c820-256d-4270-802a-c4ada528e6a0 /boot xfs defaults 0 0 UUID=0d7c481c-18db-4799-853d-86a6f0ae6fdc swap swap defaults 0 0
4.9 手動增長swap空間
#命令dd 用來操做磁盤,能夠讀,能夠寫。 if指定從哪裏讀,of指定將0寫入到哪裏,bs指定塊的大小,count=1M*100 (/dev/zero 是linux 中永遠輸出0的設備文件, 使用它做輸入能夠獲得全爲空的文件)。
[root@zgxlinux-01 ~]# dd if=/dev/zero of=/tmp/newdisk bs=1M count=100 記錄了100+0 的讀入 記錄了100+0 的寫出 104857600字節(105 MB)已複製,2.73983 秒,38.3 MB/秒 [root@zgxlinux-01 ~]# du -sh /tmp/newdisk 100M /tmp/newdisk [root@zgxlinux-01 ~]# mkswap -f /tmp/newdisk #格式化 正在設置交換空間版本 1,大小 = 102396 KiB 無標籤,UUID=27c139e5-b946-4e68-957c-04ec5139eb26 [root@zgxlinux-01 ~]# free -m total used free shared buff/cache available Mem: 983 126 595 7 261 679 Swap: 2047 0 2047 [root@zgxlinux-01 ~]# swapon /tmp/newdisk #加載到現有swap分區 swapon: /tmp/newdisk:不安全的權限 0644,建議使用 0600。 [root@zgxlinux-01 ~]# free -m total used free shared buff/cache available Mem: 983 126 595 7 261 679 Swap: 2147 0 2147 [root@zgxlinux-01 ~]# chmod 600 /tmp/newdisk [root@zgxlinux-01 ~]# swapoff /tmp/newdisk #從swap分區卸載 [root@zgxlinux-01 ~]# free -m total used free shared buff/cache available Mem: 983 126 595 7 261 679 Swap: 2047 0 2047 [root@zgxlinux-01 ~]# rm -rf /tmp/newdisk #刪除