ts-7000
[Top] [All Lists]

[ts-7000] Re: making a new Debian Linux micro disk from an old one, with

To:
Subject: [ts-7000] Re: making a new Debian Linux micro disk from an old one, with busybox linux.
From: "Jon L" <>
Date: Wed, 23 Dec 2009 16:42:08 -0000


Well it looks like it worked!   here is the log of the session with a recap below:

# dd if=/dev/nbd0p4 of=/dev/sda4
dd: can't open '/dev/nbd0p4': No such file or directory

# dd if=/dev/nbd4 of=/dev/sda4
dd: writing '/dev/sda4': No space left on device
1076545+0 records in
1076544+0 records out
# mount /dev/nbd4 /mnt/root
# mount
rootfs on / type rootfs (rw)
/dev/root on / type ext2 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw)
none on /dev/shm type tmpfs (rw)
tmpfs on /tmp type tmpfs (rw)
/dev/nbd4 on /mnt/root type ext3 (rw,data=""># df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                 2011      1277       734  64% /
none                     31456         0     31456   0% /dev/shm
tmpfs                    31456         0     31456   0% /tmp
/dev/nbd4               507748    297586    183948  62% /mnt/root
# ls /mnt
hda1     host     usbdev   usbdev2  usbdev4
hda2     root     usbdev1  usbdev3  usbdev5
# mount /dev/sda4 /mnt/usbdev4
# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                 2011      1277       734  64% /
none                     31456         0     31456   0% /dev/shm
tmpfs                    31456         0     31456   0% /tmp
/dev/nbd4               507748    297586    183948  62% /mnt/root
/dev/sda4               507748    297586    183948  62% /mnt/usbdev4
# cd /mnt/usbdev4
# ls
bin         home        mnt         sbin        tmp
boot        initrd      opt         selinux     usr
dev         lib         proc        srv         var
etc         lost+found  root        sys


1) the source partition did not like using the name (/dev/nbd0p4) as shown in the "fdisk -l /dev/nbd0" command:

# fdisk -l /dev/nbd0

Disk /dev/nbd0: 549.7 GB, 549755813888 bytes
32 heads, 63 sectors/track, 532610 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes

     Device Boot      Start         End      Blocks  Id System
/dev/nbd0p1               5          20       16128   c Win95 FAT32 (LBA)
/dev/nbd0p2              21          23        3024  da Unknown
/dev/nbd0p3              24          26        3024  da Unknown
/dev/nbd0p4              27         560      538272  83 Linux


It wanted (/dev/nbd4) as shown in the "ps" listing:

# ps
  PID USER       VSZ STAT COMMAND
    1 root       896 S    /bin/sh /linuxrc
  ...
  102 root       920 S    /bin/sh -i
  109 root       892 S    telnetd
  112 root       664 S    xuartctl --server
  116 root      2656 S    sdctl -z 65536 --nbdserver lun0:disc,lun0:part1,lun0:
  118 root       572 S    nbd-client 127.0.0.1 7500 /dev/nbd0
  120 root       572 S    nbd-client 127.0.0.1 7501 /dev/nbd1
  122 root       572 S    nbd-client 127.0.0.1 7502 /dev/nbd2
  124 root       572 S    nbd-client 127.0.0.1 7503 /dev/nbd3
  126 root       572 S    nbd-client 127.0.0.1 7504 /dev/nbd4


2) The "dd" command reported an error, but is all seemed to work ok:

# dd if=/dev/nbd4 of=/dev/sda4
dd: writing '/dev/sda4': No space left on device
1076545+0 records in
1076544+0 records out


3) This "dd" command took several minutes (10 I think) to make  the copy, with no feedback, so go get a cup of coffee.  I don't know why the size of the partition 4 is all out of sorts.


Here is a recap of what I did to make a 1GB Debian Linux Micro SD card for a TS-7500 from a 2GB Debian Linux Micro SD card:

1) equipment used: TS-7500 mounted on the development kit TS-752, the 2gb Micro SD card in the onboard slot, the 1GB target Microcard in a USB thumbdrive reader for the Microcard plugged into the top slot of the USB type A connector on the TS-7500

2) put everything together and booted the TS-7500 with the busybox default OS from embedded arm.

3) the 2gb partition 4 mounts automatically with busybox so I unmounted it with "umount /mnt/root"

4) I checked the current layout of the 2gb card by doing a "fdisk -l /dev/nbd0" command. This listed all 4 partitions, their ID, size, etc.  I saved that info for later.

5)I then did a "fdisk -l" this told me that the memory stick was /dev/sda.

6) Next is the  "fdisk /dev/sda" command.  This is where I muddled through making the 4 partitions.  the "m" commant in fdisk tells you all the options, and by repeating the "n" command for each partition, (Primary, first cylinder, +sizeK,) and the "t" command (partition number, hex code(the id) )   and checking things with the "p" command, I got the partitions to "look" about the same as the 2gb.  The only difference is I made partion 1 only 20mb, instead of 1.25gb as I was dealing with a 1gb card and not a 2gb card. The last command on the fdisk is the "w" command that actually writes your layout to the card.

7) at the time the blocks seemed to be right, but as thing progressed, they changed. I don't know why but I guess I was "good enough" sorry for the ambiguity.

8) issued the command at the busybox linux prompt "dd if=/dev/nbd4 of=/dev/sda4" to copy over the 4th partition of the 2gb card to the 4th partition of the 1gb card.  This took about 10 minutes to complete, and came back with the message:

dd: writing '/dev/sda4': No space left on device
1076545+0 records in
1076544+0 records out

but I then mounted the partition and it seemed ok.

9) Powered everything down, took out the usb thumbdrive, replaced the 2gb card with the newly created 1GB card, powered up the unit.  The busybox linux came up, I typed "exit" to boot the debian linux. Debian linux came up without a hitch.




Heres a log of my whole session complete with my typos:


# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                 2011      1277       734  64% /
none                     31456         0     31456   0% /dev/shm
tmpfs                    31456         0     31456   0% /tmp
/dev/nbd4               507748    297586    183948  62% /mnt/root
# fdisk -l

Disk /dev/sda: 1015 MB, 1015808000 bytes
32 heads, 63 sectors/track, 984 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               1         984      991747+  6 FAT16

# umount /mnt/root
# fdisk -l /dev/nbd0

Disk /dev/nbd0: 549.7 GB, 549755813888 bytes
1 heads, 62 sectors/track, 17318416 cylinders
Units = cylinders of 62 * 512 = 31744 bytes

     Device Boot      Start         End      Blocks  Id System
/dev/nbd0p1               5       42282     1310592   c Win95 FAT32 (LBA)
/dev/nbd0p2           42282       42348        2048  da Unknown
/dev/nbd0p3           42348       42414        2048  da Unknown
/dev/nbd0p4           42414       59326      524288  83 Linux
# fdisk /dev/sda
d
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
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

Command (m for help): d
Selected partition 1

Command (m for help): o
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that the previous content
won't be recoverable.


Command (m for help): d
No partition is defined yet!

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
.
.
.
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
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

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): da
Changed system type of partition 2 to da (Unknown)

Command (m for help): p

Disk /dev/sda: 1015 MB, 1015808000 bytes
32 heads, 63 sectors/track, 984 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               5          20       16128   c Win95 FAT32 (LBA)
/dev/sda2              21          23        3024  da Unknown

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1-984, default 1): 24
Last cylinder or +size or +sizeM or +sizeK (24-984, default 984): +2048K

Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): da
Changed system type of partition 3 to da (Unknown)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Selected partition 4
First cylinder (1-984, default 1): 27
Last cylinder or +size or +sizeM or +sizeK (27-984, default 984): +550M

Command (m for help): p

Disk /dev/sda: 1015 MB, 1015808000 bytes
32 heads, 63 sectors/track, 984 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               5          20       16128   c Win95 FAT32 (LBA)
/dev/sda2              21          23        3024  da Unknown
/dev/sda3              24          26        3024  da Unknown
/dev/sda4              27         560      538272  83 Linux
Command (m for help): w
The partition table has been altered!:
7)
# fdisk -l /dev/sda

Disk /dev/sda: 1015 MB, 1015808000 bytes
32 heads, 63 sectors/track, 984 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               5          20       16128   c Win95 FAT32 (LBA)
/dev/sda2              21          23        3024  da Unknown
/dev/sda3              24          26        3024  da Unknown
/dev/sda4              27         560      538272  83 Linux
 umount /mnt/root
# mount
rootfs on / type rootfs (rw)
/dev/root on / type ext2 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw)
none on /dev/shm type tmpfs (rw)
tmpfs on /tmp type tmpfs (rw)
# fdisk -l /dev/sda

Disk /dev/sda: 1015 MB, 1015808000 bytes
32 heads, 63 sectors/track, 984 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               5          20       16128   c Win95 FAT32 (LBA)
/dev/sda2              21          23        3024  da Unknown
/dev/sda3              24          26        3024  da Unknown
/dev/sda4              27         560      538272  83 Linux
# fdisk -l /dev/nbd0

Disk /dev/nbd0: 549.7 GB, 549755813888 bytes
1 heads, 62 sectors/track, 17318416 cylinders
Units = cylinders of 62 * 512 = 31744 bytes

     Device Boot      Start         End      Blocks  Id System
/dev/nbd0p1               5       42282     1310592   c Win95 FAT32 (LBA)
/dev/nbd0p2           42282       42348        2048  da Unknown
/dev/nbd0p3           42348       42414        2048  da Unknown
/dev/nbd0p4           42414       59326      524288  83 Linux
# dd if=/dev/nbd0p4 of=/dev/sda4
dd: can't open '/dev/nbd0p4': No such file or directory
# mount /dev/nbd0p4 /mnt/root
mount: mounting /dev/nbd0p4 on /mnt/root failed: No such file or directory
# dd if=/dev/nbd4 of=/dev/sda4
dd: writing '/dev/sda4': No space left on device
1076545+0 records in
1076544+0 records out
# mount /dev/nbd4 /mnt/root
# mount
rootfs on / type rootfs (rw)
/dev/root on / type ext2 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw)
none on /dev/shm type tmpfs (rw)
tmpfs on /tmp type tmpfs (rw)
/dev/nbd4 on /mnt/root type ext3 (rw,data=""># df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                 2011      1277       734  64% /
none                     31456         0     31456   0% /dev/shm
tmpfs                    31456         0     31456   0% /tmp
/dev/nbd4               507748    297586    183948  62% /mnt/root
# ls /mnt
hda1     host     usbdev   usbdev2  usbdev4
hda2     root     usbdev1  usbdev3  usbdev5
# mount /dev/sda4 /mnt/usbdev4
# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                 2011      1277       734  64% /
none                     31456         0     31456   0% /dev/shm
tmpfs                    31456         0     31456   0% /tmp
/dev/nbd4               507748    297586    183948  62% /mnt/root
/dev/sda4               507748    297586    183948  62% /mnt/usbdev4
# cd /mnt/usbdev4
# ls
bin         home        mnt         sbin        tmp
boot        initrd      opt         selinux     usr
dev         lib         proc        srv         var
etc         lost+found  root        sys

# cd home
# ls
chris    eclipse  jon      kevin
# cd jon
# ls
bash.man  programs  test
# pwd
/mnt/usbdev4/home/jon
# cd /
#
>> TS-BOOTROM - built Aug 26 2009 13:35:32
>> Copyright (c) 2009, Technologic Systems
>> Booting from onboard SPI flash...
.
.
.
Finished booting in 2.65 seconds
Type 'tshelp' for help
# mount
rootfs on / type rootfs (rw)
/dev/root on / type ext2 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw)
none on /dev/shm type tmpfs (rw)
tmpfs on /tmp type tmpfs (rw)
/dev/nbd4 on /mnt/root type ext3 (ro,data=""># exit
INIT: version 2.86 booting
Starting the hotplug events dispatcher: udevd.
Synthesizing the initial hotplug events...done.
Waiting for /dev to be fully populated...done.
Activating swap...done.
Cleaning up ifupdown....
Loading kernel modules...done.
Checking file systems...fsck 1.41.3 (12-Oct-2008)
done.
Setting kernel variables (/etc/sysctl.conf)...done.
Mounting local filesystems...done.
Activating swapfile swap...done.
Setting up networking....
Configuring network interfaces...done.
Starting portmap daemon....
Starting NFS common utilities: statd.
INIT: Entering runlevel: 2
Starting enhanced syslogd: rsyslogd.
Starting system message bus: dbus.
Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon.
Starting OpenBSD Secure Shell server: sshd.
Starting NFS common utilities: statd.
Starting internet superserver: inetd.
Starting periodic command scheduler: crond.
Starting web server: apache2.

Debian GNU/Linux 5.0 ts7500 ttyS0

ts7500 login: jleslie
Password:
Last login: Thu Jan  1 00:10:02 UTC 1970 from dhpc-1060l.dhpc.local on pts/1
Linux ts7500 2.6.24.4 #55 Fri Aug 7 11:20:02 MST 2009 armv4l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
:~$ ls
bash.man  programs  test
:~$ mount
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
rootfs on / type rootfs (rw)
/dev/root on /initrd type ext2 (rw)
devpts on /initrd/dev/pts type devpts (rw)
none on /initrd/dev/shm type tmpfs (rw)
tmpfs on /initrd/tmp type tmpfs (rw)
:~$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                    31456        16     31440   1% /lib/init/rw
udev                     10240         8     10232   1% /dev
tmpfs                    31456         0     31456   0% /dev/shm
rootfs                  507748    297622    183912  62% /
/dev/root                 2011      1277       734  64% /initrd
none                     31456         0     31456   0% /initrd/dev/shm
tmpfs                    31456         0     31456   0% /initrd/tmp
:~$
:~$
:~$



  x


--- In "Jon L" <> wrote:
>
> Skuruz,
>
> your analysis sounds very good. Busybox linux doesn't have a mkfs.ext3 command, but I think I'm past that since fdisk -l /dev/sda:
>
> # fdisk -l /dev/sda
>
> Disk /dev/sda: 1015 MB, 1015808000 bytes
> 32 heads, 63 sectors/track, 984 cylinders
> Units = cylinders of 2016 * 512 = 1032192 bytes
>
> Device Boot Start End Blocks Id System
> /dev/sda1 5 20 16128 c Win95 FAT32 (LBA)
> /dev/sda2 21 23 3024 da Unknown
> /dev/sda3 24 26 3024 da Unknown
> /dev/sda4 27 560 538272 83 Linux
>
>
> is showing the same format as the 2GB card. tech support insisted that two partitions 2 and 3 were also necessary, but who know what experience the tech guy that answered the phone actually had.
>
> If I just do the #dd command to the /dev/sda4 I should be good to go with your instructions, and I won't even have to modify the linuxrc since I made the 4 partitions anyway.
>
> I'm assuming the /dev/sdaX devices and the /dev/nbdX devices are unmounted when I do the dd command. I'll give it a try and see...
>
>
>
> --- In Serkan KÜRÜZ serkan.kuruz@ wrote:
> >
> > If u want use an 1Gb MicroSD it is easy to make it as an one partition disk.
> > (the other partitions not necessary)
> >
> > Firstly,
> >
> > - format your 1Gb disk as Ext3 (ex: #mkfs.ext3 /dev/sdc1)
> >
> > - mount the old 2Gb disk and look at the which directory debian is
> > mounted. (at your disk I think /dev/ndb0p4)
> >
> > - use dd command for copy the debian to new disk partition. (ex:
> > #dd if=/dev/ndb0p4 of=/dev/sdc1)
> >
> > Your disk is ready now.. But at the ARM busybox Linux it was setted boot SD
> > from 4 paritioned disk. So u must change it for 1 partition.
> >
> > - At busybox open the linuxrc-sdboot file (#vi linuxrc-sdboot ) and
> > change the line as following.
> >
> > mount -oro /dev/nbd4 /mnt/root -> mount -oro /dev/nbd1 /mnt/root
> >
> >
> >
> > I hope that it is useful for u.. good luck
> >
> >
> >
> > Skuruz.
> >
> >
> >
> > From: [ On Behalf Of
> > Jon L
> > Sent: Wednesday, December 23, 2009 12:10 AM
> > To:
> > Subject: [ts-7000] making a new Debian Linux micro disk from an old one,
> > with busybox linux.
> >
> >
> >
> >
> >
> > Ok I have a TS-7500 and it has on its 2GB Micro SD card 4 partitions and a
> > bootable Debian linux. The TS-7500 boots to Busybox Linux and from there I
> > can umount the SD card and see its partitions:
> >
> > # fdisk -l /dev/nbd0
> >
> > Disk /dev/nbd0: 549.7 GB, 549755813888 bytes
> > 1 heads, 62 sectors/track, 17318416 cylinders
> > Units = cylinders of 62 * 512 = 31744 bytes
> >
> > Device Boot Start End Blocks Id System
> > /dev/nbd0p1 5 42282 1310592 c Win95 FAT32 (LBA)
> > /dev/nbd0p2 42282 42348 2048 da Unknown
> > /dev/nbd0p3 42348 42414 2048 da Unknown
> > /dev/nbd0p4 42414 59326 524288 83 Linux
> >
> > so now I want to make a new Micro SD card with these same information with a
> > slight twist; I only have a 1GB Micro SD card. No real problem as I don't
> > really need the FAT partition so I can take away from that. So I install the
> > 1GB Micro SD card on the thumbdrive and plug that into the USB port of the
> > TS-7500, and make up the 4 partitions on the /dev/sda device:
> >
> > # fdisk /dev/sda
> > .......
> > .......
> > .......
> >
> > Command (m for help): p
> >
> > Disk /dev/sda: 1015 MB, 1015808000 bytes
> > 32 heads, 63 sectors/track, 984 cylinders
> > Units = cylinders of 2016 * 512 = 1032192 bytes
> >
> > Device Boot Start End Blocks Id System
> > /dev/sda1 5 20 16128 c Win95 FAT32 (LBA)
> > /dev/sda2 21 23 3024 da Unknown
> > /dev/sda3 24 26 3024 da Unknown
> > /dev/sda4 27 560 538272 83 Linux
> > Command (m for help): w
> > The partition table has been altered!:
> >
> > # fdisk -l /dev/sda
> >
> > Disk /dev/sda: 1015 MB, 1015808000 bytes
> > 32 heads, 63 sectors/track, 984 cylinders
> > Units = cylinders of 2016 * 512 = 1032192 bytes
> >
> > Device Boot Start End Blocks Id System
> > /dev/sda1 5 20 16128 c Win95 FAT32 (LBA)
> > /dev/sda2 21 23 3024 da Unknown
> > /dev/sda3 24 26 3024 da Unknown
> > /dev/sda4 27 560 538272 83 Linux
> >
> > Now for the question:
> >
> > Using the busybox linux, how do I get the contents of the 2GB's 3 partitions
> > to the 3 partitions of the 1GB card?
> >
> > This is assuming that my partitions are acceptable, so if my partitions are
> > not right please help me with them, I couldn't figure out how to make
> > partitions 2 and 3 exactly 2048 like in the original 2GB micro SD card.
> >
> > TIA,
> >
> > Jleslie48
> >
>


__._,_.___


Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: =Email Delivery: Digest | m("yahoogroups.com?subject","ts-7000-fullfeatured");=Change Delivery Format: Fully Featured">Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | =Unsubscribe

__,_._,___
<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU