DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2007-01-27 11:23:34

qn1234
Member
Registered: 2006-08-18
Posts: 94

pivot_root from USB Memory Stick

I noticed beattie's modification section in the initscripts-0.1/rc.sh file.  Looks like it tries to execute the .DSM-G600-USB-KEY-init file if exists on a USB memory stick labelled DSMG600_KEY.

It would be nice if it looks for the existence of a directory to be used as the pivot_root.  Something like:

mkdir /usbmnt && mount -L DSMG600_KEY /usbmnt
if [ -d /usbmnt/DSMG600_ROOT ]; then
    cd /usbmnt/DSMG600_ROOT
    /sbin/pivot_root . <oldroot>
    ...
fi

At this time, the initrd is already loaded into memory, we need to free it up using:
   fd = open("/dev/ram0", O_RDWR);
   ioctl(fd, BLKFLSZBUF);
   close(fd);

--
Quang

Offline

 

#2 2007-01-27 19:23:13

beattie
Member / Developer
From: West Coast, USA
Registered: 2006-11-17
Posts: 92
Website

Re: pivot_root from USB Memory Stick

qn1234 wrote:

I noticed beattie's modification section in the initscripts-0.1/rc.sh file.  Looks like it tries to execute the .DSM-G600-USB-KEY-init file if exists on a USB memory stick labelled DSMG600_KEY.

It would be nice if it looks for the existence of a directory to be used as the pivot_root.  Something like:

mkdir /usbmnt && mount -L DSMG600_KEY /usbmnt
if [ -d /usbmnt/DSMG600_ROOT ]; then
    cd /usbmnt/DSMG600_ROOT
    /sbin/pivot_root . <oldroot>
    ...
fi

Could you explain how this is an improvement?.

qn1234 wrote:

At this time, the initrd is already loaded into memory, we need to free it up using:
   fd = open("/dev/ram0", O_RDWR);
   ioctl(fd, BLKFLSZBUF);
   close(fd);

--
Quang

I'll look into this.

Offline

 

#3 2007-01-28 03:33:54

qn1234
Member
Registered: 2006-08-18
Posts: 94

Re: pivot_root from USB Memory Stick

beattie wrote:

Could you explain how this is an improvement?

This allows you to use your own ramdisk freeing up the original one.

--
Quang

Offline

 

#4 2007-01-28 08:58:48

beattie
Member / Developer
From: West Coast, USA
Registered: 2006-11-17
Posts: 92
Website

Re: pivot_root from USB Memory Stick

qn1234 wrote:

beattie wrote:

Could you explain how this is an improvement?

This allows you to use your own ramdisk freeing up the original one.

--
Quang

I guess, unless there is a reason otherwise I'd suggest that you what you need to do in /mnt/pivot_root/.DSM-G600-USB-KEY-init, which is what I did.  I don't want to place any restrictions on what can be done in that file. For Instance here is one version of .DSM-G600-USB-KEY-init. that I tested:

Code:

#! /bin/sh

cd /mnt/pivot_root
umount /sys/crfs
losetup -d /dev/loop0
umount /proc
pivot_root /mnt/pivot_root /mnt/pivot_root
exec chroot / /bin/ash
echo $0

Last edited by beattie (2007-01-28 09:10:43)

Offline

 

#5 2007-01-28 09:22:04

qn1234
Member
Registered: 2006-08-18
Posts: 94

Re: pivot_root from USB Memory Stick

What you have right now would work just fine. 

By the way, you probably fixed it - I noticed you have a command misspelled in the rc.sh file.  It's supposed to be "unmount".

--
Quang

Offline

 

#6 2007-01-29 00:25:24

beattie
Member / Developer
From: West Coast, USA
Registered: 2006-11-17
Posts: 92
Website

Re: pivot_root from USB Memory Stick

qn1234 wrote:

What you have right now would work just fine. 

By the way, you probably fixed it - I noticed you have a command misspelled in the rc.sh file.  It's supposed to be "unmount".

--
Quang

Are you saying I have a command named "unmount" in my script? or the command "umount" is misspelled?

There is no command "unmount", the correct command is "umount" this spelling goes back to early Unix versions.

Offline

 

#7 2007-01-29 00:41:42

sala
Member / Site Admin
From: Estonia
Registered: 2006-07-28
Posts: 731
Website

Re: pivot_root from USB Memory Stick

Relax guys big_smile
There was "uount /sys/cfs" or something like that.
And about Dlink, they like to use "ehco" commands and empty if and do statements big_smile


DSM-G600 - NetBSD hdd-boot - 80GB Samsung SP0802N
NSA-220 - Gentoo armv5tel 20110121 hdd-boot - 2x 2TB WD WD20EADS

Offline

 

#8 2007-01-29 04:34:29

qn1234
Member
Registered: 2006-08-18
Posts: 94

Re: pivot_root from USB Memory Stick

sala wrote:

Relax guys big_smile
There was "uount /sys/cfs" or something like that.
And about Dlink, they like to use "ehco" commands and empty if and do statements big_smile

Yeah, I meant to say I saw "uount /sys/cfs".  Sometimes being up too late at night you got to misspell something. smile

--
Quang

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB