linux制作ext2磁盘镜像,linux--创建镜像挂载
1、創建磁盤鏡像文件
[root@localhost tmp]# dd if=/dev/zero of=floppy.img bs=512 count=2880
記錄了2880+0 的讀入
記錄了2880+0 的寫出
1474560 bytes (1.5 MB, 1.4 MiB) copied, 0.00571329 s, 258 MB/s
[root@localhost tmp]# ll
總用量 1.5M
-rw-------. 1 root root 1.5M 4月 17 00:11 floppy.img
2、查看loop設備
一般在linux中會有8個loop設備,一般是/dev/loop0~loop7,可用通過losetup -a查看所有的loop設備,如果命令沒有輸出就說明所有的loop設備都沒有被占用
[root@localhost tmp]# losetup -a
[root@localhost tmp]#
3、將文件轉換為塊設備
[root@localhost tmp]# losetup /dev/loop0 /tmp/floppy.img
[root@localhost tmp]# losetup -a
/dev/loop0: [0041]:58360 (/tmp/floppy.img)
[root@localhost tmp]#
4、創建掛載點
[root@localhost tmp]# mkdir /mnt/tmp
[root@localhost tmp]#
5、格式化塊設備
[root@localhost tmp]# mkfs.ext2 /dev/loop0
mke2fs 1.45.3 (14-Jul-2019)
丟棄設備塊: 完成
創建含有 1440 個塊(每塊 1k)和 184 個inode的文件系統
正在分配組表: 完成
正在寫入inode表: 完成
寫入超級塊和文件系統賬戶統計信息: 已完成
[root@localhost tmp]#
6、掛載
[root@localhost tmp]# mount /dev/loop0 /mnt/tmp
[root@localhost tmp]# cd /mnt/tmp
[root@localhost tmp]# ll
總用量 12K
drwx------. 2 root root 12K 4月 17 00:23 lost+found
[root@localhost tmp]# touch demo
[root@localhost tmp]#
7、卸載loop設備
[root@localhost tmp]# losetup -d /dev/loop0
8、卸載掛載
[root@localhost tmp]# umount /mnt/tmp
總結
以上是生活随笔為你收集整理的linux制作ext2磁盘镜像,linux--创建镜像挂载的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: arch linux 同步时间,Arch
- 下一篇: linux中and运算符文件重定向,li