如何制作ubuntu系统使用Ubuntu制作ext4文件系统ubuntu创建ext4文件系统




如何制作ubuntu系统使用Ubuntu制作ext4文件系统ubuntu创建ext4文件系统

2022-07-20 21:51:39 网络知识 官方管理员

本文基于Ubuntu18.04系统,在U盘中制作ext4文件系统。在嵌入式调试中,可以从U盘中挂载文件系统。

#1、查看U盘设备目录root@ubuntu:/home/run/code#ls/dev/sdsdasda1sdbsdb1(U盘)#2、卸载root@ubuntu:/home/run/code#umount/dev/sdb1#3、格式化为ext4文件系统,并添加卷标‘rootfs’root@ubuntu:/home/run/code#mkfs.ext4-Lrootfs/dev/sdb1mke2fs1.44.1(24-Mar-2018)Creatingfilesystemwith78640594kblocksand1966080inodesFilesystemUUID:d20aee9e-3ada-4f3e-b806-9bbad7209362Superblockbackupsstoredonblocks:32768,98304,163840,229376,294912,819200,884736,1605632,2654208,4096000Allocatinggrouptables:doneWritinginodetables:doneCreatingjournal(32768blocks):doneWritingsuperblocksandfilesystemaccountinginformation:doneroot@ubuntu:/home/run/code##4、重新拔插U盘#5、拷贝已有文件系统映像ubuntu_rootfs.imgroot@ubuntu:/home/run/code#fileubuntu_rootfs.imgubuntu_rootfs.img:Linuxrev1.0ext4filesystemdata,UUID=faf10ee9-7e64-4826-98cc-239708736642,volumename"rootfs"(extents)(64bit)(largefiles)(hugefiles)root@ubuntu:/home/run/code#mkdirtestimgroot@ubuntu:/home/run/code#mountubuntu_rootfs.imgtestimg/root@ubuntu:/home/run/code#cdtestimg/root@ubuntu:/home/run/code/testimg#lsbinbootdevetchomeliblost+foundmediaoptprocrootrunsbinsrvsyssystemtmpusrvarvendorroot@ubuntu:/home/run/code/testimg#mount/dev/sdb1/tmp/root@ubuntu:/home/run/code/testimg#cp-rf*/tmp/#6、卸载root@ubuntu:/home/run/code/testimg#umount/tmp

如果原有U盘有多个分区,可以使用fdisk命令删除或创建分区,流程如下:

root@ubuntu:/home/run/code#fdisk/dev/sdcWelcometofdisk(util-linux2.31.1).Changeswillremaininmemoryonly,untilyoudecidetowritethem.Becarefulbeforeusingthewritecommand.Command(mforhelp):m##1、帮助Help:GenericddeleteapartitionFlistfreeunpartitionedspacellistknownpartitiontypesnaddanewpartitionpprintthepartitiontabletchangeapartitiontypevverifythepartitiontableiprintinformationaboutapartitionMiscmprintthismenuxextrafunctionality(expertsonly)ScriptIloaddisklayoutfromsfdiskscriptfileOdumpdisklayouttosfdiskscriptfileSave&ExitwwritetabletodiskandexitqquitwithoutsavingchangesCreateanewlabelgcreateanewemptyGPTpartitiontableGcreateanewemptySGI(IRIX)partitiontableocreateanewemptyDOSpartitiontablescreateanewemptySunpartitiontableCommand(mforhelp):p##2、显示分区Disk/dev/sdc:30GiB,32212254720bytes,62914560sectorsUnits:sectorsof1*512=512bytesSectorsize(logical/physical):512bytes/512bytesI/Osize(minimum/optimal):512bytes/512bytesDisklabeltype:gptDiskidentifier:23000000-0000-4C4A-8000-699000005ABBDeviceStartEndSectorsSizeType/dev/sdc1163842457581924Munknown/dev/sdc2245763276781924Munknown/dev/sdc332768983036553632Munknown/dev/sdc4983041638396553632Munknown/dev/sdc51638402293756553632Munknown/dev/sdc6229376432332740939522Gunknown/dev/sdc74323328629144955859116828GunknownCommand(mforhelp):d##3、删除分区7-1Partitionnumber(1-7,default7):7Partition7hasbeendeleted.Command(mforhelp):dPartitionnumber(1-6,default6):Partition6hasbeendeleted.Command(mforhelp):dPartitionnumber(1-5,default5):Partition5hasbeendeleted.Command(mforhelp):dPartitionnumber(1-4,default4):Partition4hasbeendeleted.Command(mforhelp):dPartitionnumber(1-3,default3):Partition3hasbeendeleted.Command(mforhelp):dPartitionnumber(1,2,default2):dValueoutofrange.Partitionnumber(1,2,default2):Partition2hasbeendeleted.Command(mforhelp):dSelectedpartition1Partition1hasbeendeleted.Command(mforhelp):p##4、显示分区Disk/dev/sdc:30GiB,32212254720bytes,62914560sectorsUnits:sectorsof1*512=512bytesSectorsize(logical/physical):512bytes/512bytesI/Osize(minimum/optimal):512bytes/512bytesDisklabeltype:gptDiskidentifier:23000000-0000-4C4A-8000-699000005ABBCommand(mforhelp):n##5、新建分区1Partitionnumber(1-128,default1):Firstsector(34-62914526,default2048):Lastsector,+sectorsor+size{K,M,G,T,P}(2048-62914526,default62914526):Createdanewpartition1oftype'Linuxfilesystem'andofsize30GiB.Partition#1containsaext4signature.Doyouwanttoremovethesignature?[Y]es/[N]o:yThesignaturewillberemovedbyawritecommand.Command(mforhelp):pDisk/dev/sdc:30GiB,32212254720bytes,62914560sectorsUnits:sectorsof1*512=512bytesSectorsize(logical/physical):512bytes/512bytesI/Osize(minimum/optimal):512bytes/512bytesDisklabeltype:gptDiskidentifier:23000000-0000-4C4A-8000-699000005ABBDeviceStartEndSectorsSizeType/dev/sdc12048629145266291247930GLinuxfilesystemFilesystem/RAIDsignatureonpartition1willbewiped.Command(mforhelp):w##6、保存退出Thepartitiontablehasbeen altered.Callingioctl()tore-readpartitiontable.Syncingdisks.root@ubuntu:/home/run/code#

发表评论:

最近发表
网站分类
标签列表