日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux 增加回环设备,linux命令练习:mount fdisk swap dd创建本地回环设备

發(fā)布時間:2025/5/22 linux 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux 增加回环设备,linux命令练习:mount fdisk swap dd创建本地回环设备 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

練習(xí)一

1、創(chuàng)建一個1G的分區(qū),文件系統(tǒng)為ext4,卷標(biāo)為MYDATA,塊大小為1024,預(yù)留管理空間為磁盤

分區(qū)的3%,要求開機后制動掛載至/data目錄,并且自動掛載的設(shè)備要使用卷標(biāo)進行引用。

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 ?新建分區(qū),如果是個新硬盤會提示新建主分區(qū)(p)或者是擴展分區(qū)(e)

First cylinder (2258-2611, default 2258): ? 輸入起始柱面默認(rèn)即可

Using default value 2258

Last cylinder, +cylinders or +size{K,M,G} (2258-2611, default 2611): +1G ?創(chuàng)建一個1G分區(qū)

Command (m for help):?t ? ?t修改分區(qū)類型

Partition number (1-8):?8

Hex code (type L to list codes):?L ? L查看系統(tǒng)支持的分區(qū)類型

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 ? 輸入分區(qū)類型

Command (m for help):?p ?顯示已經(jīng)建立好的分區(qū)表

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即為剛才新建立的分區(qū)

ommand (m for help):?w ? w保存退出新建分區(qū)建立成功

The partition table has been altered!

Calling ioctl() to re-read partition table.

[root@xuelinux ~]#?partprobe ? ?partprobe通知內(nèi)核重讀分區(qū)表,讓內(nèi)核識別新建的分區(qū)

[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 ??內(nèi)核已經(jīng)識別到新建分區(qū),只有識別到了分區(qū)才能進行格式化、掛載等操作。

[root@xuelinux ~]#?mke2fs -t ext4 /dev/sda8 ? 把/dev/sda8分區(qū)格式化為ext4類型

[root@xuelinux test]#mke2fs -L?MYDATA?/dev/sda8 ? ? 設(shè)定新卷標(biāo)為MYDATA

[root@xuelinux test]#?mke2fs -m 3 /dev/sda8 ? ?預(yù)留分區(qū)的3%給管理空間

[root@xuelinux test]#mke2fs -b 1024 /dev/sda8 ? 設(shè)置塊大小為1024字節(jié)

然后把新建的分區(qū)寫入/etc/fstab文檔中,實現(xiàn)開機自動掛載,在該文檔的最下面添加一行如下:

LABEL='MYDATA'/data? ? ext4 ? ? ? defaults ? ? 0 ? ? ?0

實現(xiàn)卷標(biāo)自動掛載為MYDATA

練習(xí)二

2、創(chuàng)建一個本地回環(huán)文件/var/swaptemp/swapfile來用于swap,要求大小為512MB,

卷標(biāo)為SWAP-FILE,且開機自動啟用此交換設(shè)備:

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實現(xiàn)開機自動掛載

練習(xí)三

3、實現(xiàn)自動掛載并同時啟用acl功能

vim /etc/fstab

LABEL='MYDATA'/data? ? ext4 ? ? ? defaults,acl? ? ?0 ? ? ?0 ? 實現(xiàn)自動掛的同時啟用ACL功能

總結(jié)

以上是生活随笔為你收集整理的linux 增加回环设备,linux命令练习:mount fdisk swap dd创建本地回环设备的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。