10/14/2014

FILE SYSTEM의 IMAGE 수정 (추후 TEST 완료 후 삭제)

1. 목적

기존에 존재하던 image 파일을 수정하여 새로운 image 파일을 만드는 것이 목적.
TI에서 제공하는 Filesystem  사용
  • emmc_backup_2014_90_30.img의 filesystem을 지우고, TI-Filesystem 대체
  • emmc_backup_2014_90_30.img resize 

2. Image 수정

FAT는 Boot file이기에 건들지 않고, Linux File system만 외부의 파일 system에서 가져와
새로 파티션을 만들어 수정한다.

2.1 각각의 Image 구성 확인

  • 각 구성은 1. boot   2. Linux filesystem 으로 구성 

$ fdisk -l /media/sf_SHARED/emmc_backup_2014_09_30.img 

Disk /media/sf_SHARED/emmc_backup_2014_09_30.img: 7818 MB, 7818182656 bytes
255 heads, 63 sectors/track, 950 cylinders, total 15269888 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c4046

                                      Device Boot      Start         End      Blocks   Id  System
/media/sf_SHARED/emmc_backup_2014_09_30.img1            4096      266239      131072    b  W95 FAT32
/media/sf_SHARED/emmc_backup_2014_09_30.img2          266240    11532287     5633024   83  Linux  

2.2  Image 수정 

두번째 파티션 지우고 동시에 새로운 파티션을 만드며,각 사이즈를 정하고, Sector 크기를
2의 배수로 정한다. ( 1 Block이 2 Sector)

 $ fdisk /media/sf_SHARED/emmc_backup_2014_09_30.img 

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): d
Partition number (1-4): 2

Command (m for help): p

Disk /media/sf_SHARED/emmc_backup_2014_09_30.img: 7818 MB, 7818182656 bytes
255 heads, 63 sectors/track, 950 cylinders, total 15269888 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c4046

                                      Device Boot      Start         End      Blocks   Id  System
/media/sf_SHARED/emmc_backup_2014_09_30.img1            4096      266239      131072    b  W95 FAT32

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (1-4, default 2): 2
First sector (2048-15269887, default 2048): 266240
Last sector, +sectors or +size{K,M,G} (266240-15269887, default 15269887): 1712089        //1606499 -160650 = 1712089            

Command (m for help): p

Disk /media/sf_SHARED/emmc_backup_2014_09_30.img: 7818 MB, 7818182656 bytes
255 heads, 63 sectors/track, 950 cylinders, total 15269888 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c4046

                                      Device Boot      Start         End      Blocks   Id  System
/media/sf_SHARED/emmc_backup_2014_09_30.img1            4096      266239      131072    b  W95 FAT32
/media/sf_SHARED/emmc_backup_2014_09_30.img2          266240     1712089      722925   83  Linux

Command (m for help): w


2.3 Image Resizing

위의 emmc_backup_2014_09_30.img 의 경우 아직 7818MB이며, 15269888 sectors 사용중 하지만 우리의 새로운 image의 end는
아래와 같이 dd 명령어를 사용해서, image를 resize를 한다.

마지막 sector가 1712089 이고 해서, 이를 짝수를 맞추고, 여분을 주기위해서, +1011줌.
현재 1 block = 2 sectors
* bs  size에 속도차이가 심함

count 값은 위의 sectors 값을 반으로 나눈값 , bs를 변경 해도 됨

 $ dd if=/media/sf_SHARED/emmc_backup_2014_09_30.img of=/media/sf_SHARED/test_newImage.img  bs=1k count=$(((1712089+1011)/2)) 

결과물로 test_newImage.img

3. Filesystem 복사

$ fdisk -l /media/sf_SHARED/test_newImage.img 

Disk /media/sf_SHARED/test_newImage.img: 877 MB, 877107200 bytes
255 heads, 63 sectors/track, 106 cylinders, total 1713100 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c4046

                             Device Boot      Start         End      Blocks   Id  System
/media/sf_SHARED/test_newImage.img1            4096      266239      131072    b  W95 FAT32
/media/sf_SHARED/test_newImage.img2          266240     1712089      722925   83  Linux  

 $ fdisk -l /media/sf_SHARED/TI-IMAGE.img 

Disk /media/sf_SHARED/TI-IMAGE.img: 3965 MB, 3965190144 bytes
255 heads, 63 sectors/track, 482 cylinders, total 7744512 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

                        Device Boot      Start         End      Blocks   Id  System
/media/sf_SHARED/TI-IMAGE.img1   *          63      144584       72261    c  W95 FAT32 (LBA)
/media/sf_SHARED/TI-IMAGE.img2          160650     1606499      722925   83  Linux
/media/sf_SHARED/TI-IMAGE.img3         1606500     7743329     3068415   83  Linux 

3.1 Filesystem 복사 방법 

A.   Mount 복사

$ sudo mount -o loop,offset=$((512 * 266240)) /media/sf_SHARED/test_newImage.img  ./tmp1
mount: wrong fs type, bad option, bad superblock on /dev/loop1,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

$ sudo mount -o loop,offset=$((512 * 160650)) /media/sf_SHARED/TI-IMAGE.img       ./tmp2  

      skip =  input block  offset
      seek = output block offset

위에서 에러가 나서, 그냥 dd로 전부 copy

B.   dd를 이용하여 복사 


 $ dd if=/media/sf_SHARED/TI-IMAGE.img of=/media/sf_SHARED/test_newImage.img  bs=512 skip=160650 seek=266240 count=$((1606499-160650)) 

위와 같이 여러번 했으나, 에러 발생으로 다른 방법시도
    참조:  http://forum.falinux.com/zbxe/index.php?document_srl=561988&mid=lecture_tip

C.  mkfs.ext4 와 losetup 을 이용 

$ sudo losetup -o$((512 * 266240)) /dev/loop0 /media/sf_SHARED/test_newImage.img   //attach device
$ sudo mkfs -t ext4 /dev/loop0
$ sudo losetup -d /dev/loop0   //detach device  


$ sudo mount -o loop,offset=$((512 * 266240)) /media/sf_SHARED/test_newImage.img  ./tmp1  
EXT4-fs (loop0): bad geometry: block count 1408255 exceeds size of device (214137 blocks) 

* 에러 메시지를 보고, 안되는 이유가 파티션의 사이즈 배분을 잘못해서 문제생김.

3.2  File system 복사 ( Porting Qt  및 기타 사항)
 
$ sudo mount -o loop,offset=$((512 * 266240))  /media/sf_SHARED/emmc_backup_2014_09_30.img ./tmp1
$ sudo mount -o loop,offset=$((512 * 160650)) /media/sf_SHARED/TI-IMAGE.img       ./tmp2 
$ cd tmp1
$ sudo rm -rf *
$ sudo cp -a ../tmp2/* .
$ cd usr/local
$ sudo cp -a /usr/local/Qt-4.8.6 .
 

3.3  SD 카드 이용시  할 경우

추후, TEST SD 카드 변경하여 아래와 같이 변경

$ sudo mount -o loop,offset=$((512 * 266240))  /media/sf_SHARED/emmc_backup_2014_09_30.img ./tmp1
$ sudo mount -o loop,offset=$((512 * 160650)) /media/sf_SHARED/TI-IMAGE.img                ./tmp2 
$ sudo umount tmp1 tmp2


1. lib/module 복사
2.  dev  복사  
3.  etc/rc5.d 수정  
       S02dbus-1  S20netperf  S20syslog  S90mount-sdcard  S98parse-ip
4. sudo vi inittab //commnad line보고 수정, tty1 가상 console 
              S:2345:respawn:/sbin/getty 115200 ttySAC1 
5.  sudo vi ../init.d/mount-sdcard  // 현재 UUID로 마운트 필요없는 부분제거 
6. /lib/ld-linux-armhf.so.3  loader 복사 
7.  QT 복사 
8. EMA 복사 
9. sudo ln -s libcmirisLib2_arm_2.1.3.so libcmirisLib2_arm_2.1.1.so  //usr/local/lib 

export LD_LIBRARY_PATH=/usr/lib:/lib:/usr/local/Qt-4.8.6/lib:/usr/local/lib
export QWS_DISPLAY="LinuxFb:/dev/fb6"
export PATH=$PATH:/usr/local/bin

TEST 
     cd /usr/local/
     ./deform -qws -display LinuxFb:/dev/fb6 

댓글 없음 :