嵌入式爱好者

挂载文件系统

2023-7-29 16:10| 发布者: hai| 查看: 106| 评论: 0|原作者: hai

类目: LS1012A/LS1043A/LS1046A系列产品  >  Ubuntu     文档编号: 1072

背景

如果想对文件系统进行修改后批量烧写,可以参照以下的方法。

挂载文件系统镜像

本次以FCU2201ubuntu.img进行挂载并修改,实现批量烧写(其他的ls10xx系列通用)。

1. ubuntu.img拷贝到虚拟机中,并把格式修改为可挂载的img文件。

root@ubuntu:~# mkdir ubuntu            //创建文件夹

root@ubuntu:~# cp /mnt/hgfs/镜像/Ubuntu_images/ubuntu.img ./ubuntu/       //将共享文件夹的内容拷贝到ubuntu文件夹中

root@ubuntu:~# ls ./ubuntu/

ubuntu.img

root@ubuntu:~/ubuntu# simg2img ubuntu.img ubuntu_raw.img        //更改为img格式文件

root@ubuntu:~/ubuntu# ls

ubuntu.img  ubuntu_raw.img

注:如没simg2img  img2simg命令,请使用sudo apt-get install simg2img img2simg进行下载。

 

2. 通过mount命令挂载镜像

root@ubuntu:~# mkdir modify_ubuntu       //创建挂载目录文件夹

root@ubuntu:~# sudo mount ubuntu/ubuntu_raw.img modify_ubuntu

root@ubuntu:~# cd modify_ubuntu/

root@ubuntu:~/modify_ubuntu# ls

bin  boot  dev  etc  home  include  lib  lost+found  media  mnt  opt  proc  root  run  sbin  share  srv  sys  tmp  usr  var

 

3. modify_ubuntu设置为根目录,修改网口IP文件。

root@ubuntu:~/modify_ubuntu# chroot ./    //将此目录设为跟文件目录

root@ubuntu:/# ls

bin  boot  dev etc  home  include  lib  lost+found  media  mnt  opt  proc  root  run  sbin  share  srv  sys  tmp  usr var

root@ubuntu:/# vi /etc/systemd/network/eth0.network

 

/*****************************修改为以下内容***********************************/

[Match]

Name=eth0

KernelCommandLine=!root=/dev/nfs

 

[Network]

#Bridge=br0

Address=172.16.0.245/16

Gateway=172.16.0.1

/********************************************************************************/

 

4. 使用命令exit退出,再把ubuntu_raw.img变回simg格式。

root@ubuntu:/# exit

root@ubuntu:~# sudo umount /home/forlinx/modify_ubuntu   //解除挂载

root@ubuntu:~# ls modify_ubuntu/

root@ubuntu:~# cd ubuntu/

root@ubuntu:~/ubuntu# img2simg ubuntu_raw.img ubuntu_ok.img

root@ubuntu:~/ubuntu# ls

ubuntu.img  ubuntu_ok.img  ubuntu_raw.img

5. ubuntu_ok.img拷贝到烧写镜像中并改名为ubuntu.img进行烧写,查看效果。


已解决

未解决

只是看看

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2024-5-3 04:27

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

返回顶部