linux 增加回环设备,linux命令练习:mount fdisk swap dd创建本地回环设备
練習一
1、創建一個1G的分區,文件系統為ext4,卷標為MYDATA,塊大小為1024,預留管理空間為磁盤
分區的3%,要求開機后制動掛載至/data目錄,并且自動掛載的設備要使用卷標進行引用。
fdisk /dev/sda
[root@xuelinux ~]#?fdisk /dev/sda
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 ?新建分區,如果是個新硬盤會提示新建主分區(p)或者是擴展分區(e)
First cylinder (2258-2611, default 2258): ? 輸入起始柱面默認即可
Using default value 2258
Last cylinder, +cylinders or +size{K,M,G} (2258-2611, default 2611): +1G ?創建一個1G分區
Command (m for help):?t ? ?t修改分區類型
Partition number (1-8):?8
Hex code (type L to list codes):?L ? L查看系統支持的分區類型
0 ?Empty ? ? ? ? ? 24 ?NEC DOS ? ? ? ? 81 ?Minix / old Lin bf ?Solaris
1 ?FAT12 ? ? ? ? ? 39 ?Plan 9 ? ? ? ? ?82 ?Linux swap / So c1 ?DRDOS/sec (FAT-
2 ?XENIX root ? ? ?3c ?PartitionMagic ?83 ?Linux ? ? ? ? ? c4 ?DRDOS/sec (FAT-
3 ?XENIX usr ? ? ? 40 ?Venix 80286 ? ? 84 ?OS/2 hidden C: ?c6 ?DRDOS/sec (FAT-
4 ?FAT16 <32M ? ? ?41 ?PPC PReP Boot ? 85 ?Linux extended ?c7 ?Syrinx
5 ?Extended ? ? ? ?42 ?SFS ? ? ? ? ? ? 86 ?NTFS volume set da ?Non-FS data
Hex code (type L to list codes):?83 ? 輸入分區類型
Command (m for help):?p ?顯示已經建立好的分區表
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x0001e9b8
Device Boot ? ? ?Start ? ? ? ? End ? ? ?Blocks ? Id ?System
/dev/sda1 ? * ? ? ? ? ? 1 ? ? ? ? ?26 ? ? ?204800 ? 83 ?Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 ? ? ? ? ? ? ?26 ? ? ? ?1046 ? ? 8192000 ? 83 ?Linux
/dev/sda3 ? ? ? ? ? ?1046 ? ? ? ?1556 ? ? 4096000 ? 83 ?Linux
/dev/sda4 ? ? ? ? ? ?1556 ? ? ? ?2611 ? ? 8477696 ? ?5 ?Extended
/dev/sda5 ? ? ? ? ? ?1556 ? ? ? ?1811 ? ? 2048000 ? 83 ?Linux
/dev/sda6 ? ? ? ? ? ?1811 ? ? ? ?2066 ? ? 2048000 ? 83 ?Linux
/dev/sda7 ? ? ? ? ? ?2066 ? ? ? ?2258 ? ? 1536000 ? 82 ?Linux swap / Solaris
/dev/sda8 ? ? ? ? ? ?2258 ??2389 ? ? 1059691 ??83 ?Linux
sda8即為剛才新建立的分區
ommand (m for help):?w ? w保存退出新建分區建立成功
The partition table has been altered!
Calling ioctl() to re-read partition table.
[root@xuelinux ~]#?partprobe ? ?partprobe通知內核重讀分區表,讓內核識別新建的分區
[root@xuelinux ~]# cat /proc/partitions
major minor ?#blocks ?name
8 ? ? ? ?0 ? 20971520 sda
8 ? ? ? ?1 ? ? 204800 sda1
8 ? ? ? ?2 ? ?8192000 sda2
8 ? ? ? ?3 ? ?4096000 sda3
8 ? ? ? ?4 ? ? ? ? ?1 sda4
8 ? ? ? ?5 ? ?2048000 sda5
8 ? ? ? ?6 ? ?2048000 sda6
8 ? ? ? ?7 ? ?1536000 sda7
8 ? ? ? ?8 ? ?1024000 sda8 ??內核已經識別到新建分區,只有識別到了分區才能進行格式化、掛載等操作。
[root@xuelinux ~]#?mke2fs -t ext4 /dev/sda8 ? 把/dev/sda8分區格式化為ext4類型
[root@xuelinux test]#mke2fs -L?MYDATA?/dev/sda8 ? ? 設定新卷標為MYDATA
[root@xuelinux test]#?mke2fs -m 3 /dev/sda8 ? ?預留分區的3%給管理空間
[root@xuelinux test]#mke2fs -b 1024 /dev/sda8 ? 設置塊大小為1024字節
然后把新建的分區寫入/etc/fstab文檔中,實現開機自動掛載,在該文檔的最下面添加一行如下:
LABEL='MYDATA'/data? ? ext4 ? ? ? defaults ? ? 0 ? ? ?0
實現卷標自動掛載為MYDATA
練習二
2、創建一個本地回環文件/var/swaptemp/swapfile來用于swap,要求大小為512MB,
卷標為SWAP-FILE,且開機自動啟用此交換設備:
mkdir /var/swaptemp
dd if=/dev/zero of=/var/swaptemp/swapfile?bs=512M count=1
mkswap LABEL=SWAP-FILE /var/swaptemp/swapfile
vim ?/etc/fstab
/var/swaptemp/swapfile ? swap ? swap ? ?defaults ? 0 ? 0 ?寫入/etc/fstab實現開機自動掛載
練習三
3、實現自動掛載并同時啟用acl功能
vim /etc/fstab
LABEL='MYDATA'/data? ? ext4 ? ? ? defaults,acl? ? ?0 ? ? ?0 ? 實現自動掛的同時啟用ACL功能
總結
以上是生活随笔為你收集整理的linux 增加回环设备,linux命令练习:mount fdisk swap dd创建本地回环设备的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ntfs分区对linux的局限,如何使L
- 下一篇: c语言作业集答案,C语言习题集及答案