Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
As my ISP blocks all ports below 1024 and I do not have a router for NAT I would like to change the proftpd ftp-server settings on my ix4-300d.
I have found some dpkg strings on the filesystem so I suppose it is debian based. I found the configuration file but it is read-only. It is located at
Code:
./mnt/apps/usr/local/cfg/proftpd.xml
When I try to chmod it to rw I get a file system read-only error. When I try to umount and remount I get a busy error with 20 processes which I'm not sure that are safe to kill. Here is an overview of the mount:
Code:
root@iom-server:/initrd# mount
rootfs on / type rootfs (rw)
/dev/root.old on /initrd type ext2 (rw,relatime,errors=continue)
none on / type tmpfs (rw,relatime,size=51200k,nr_inodes=63950)
ubi0:boot on /boot type ubifs (rw,sync,noatime)
/dev/md0_vg/BFDlv on /mnt/boot type ext2 (rw,noatime,errors=continue)
/dev/loop0 on /mnt/apps type ext2 (ro,relatime)
/dev/loop1 on /mnt/etc type ext2 (rw,sync,noatime)
none on /etc type unionfs (rw,sync,noatime,dirs=/mnt/etc=rw:/mnt/apps/etc=ro)
/dev/loop2 on /oem type squashfs (ro,relatime)
proc on /proc type proc (rw,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
none on /proc/fs/nfsd type nfsd (rw,relatime)
none on /sys type sysfs (rw,relatime)
tmpfs on /mnt/apps/lib/init/rw type tmpfs (rw,nosuid,relatime,mode=755)
tmpfs on /dev type tmpfs (rw,relatime,size=10240k,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,relatime)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620)
/dev/mapper/md0_vg-vol1 on /mnt/system type ext4 (rw,noatime,user_xattr,barrier= 1,data=ordered)
/dev/mapper/2f28cb78_vg-lv3d7cb3b1 on /mnt/pools/A/A0 type ext4 (rw,noatime,noui d32,user_xattr,barrier=0,data=ordered)
/dev/mapper/2f28cb78_vg-lv3d7cb3b1 on /nfs/Software type ext4 (rw,noatime,nouid3 2,user_xattr,barrier=0,data=ordered)
/dev/mapper/2f28cb78_vg-lv3d7cb3b1 on /nfs/Films type ext4 (rw,noatime,nouid32,u ser_xattr,barrier=0,data=ordered)
/dev/mapper/2f28cb78_vg-lv3d7cb3b1 on /nfs/Torrents type ext4 (rw,noatime,nouid3 2,user_xattr,barrier=0,data=ordered)
/dev/mapper/2f28cb78_vg-lv3d7cb3b1 on /nfs/Backup type ext4 (rw,noatime,nouid32, user_xattr,barrier=0,data=ordered)
/dev/mapper/2f28cb78_vg-lv3d7cb3b1 on /nfs/QuikTransfer type ext4 (rw,noatime,no uid32,user_xattr,barrier=0,data=ordered)
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
The most important line is:
Code:
/dev/loop0 on /mnt/apps type ext2 (ro,relatime)
As killing all the processes is not a very good option I went to look where the loop device was mounted as read-only. I found this in the ~/initrd/common.sh file (which is writable):
Code:
###
# Search for and execute (if found) preimage script.
###
run_preimage_script()
{
preimage_script=/usb_drive/emctools/h4c_images/preimage.sh
echo -n "Checking for pre-image script... "
if [ -x $preimage_script ]
then
echo "found."
$preimage_script
return $?
else
echo "none."
return 0
fi
}
###
# Extract a platform imager upgrade file. Validate each invidual image
# via md5 checksum.
###
extract_validate_image()
{
IMAGES="apps config initrd zImage"
USB_IMAGER_IMAGE=/usb_drive/emctools/h4c_images/*.tgz
NoExtractionFile=/usb_drive/emctools/h4c_images/noextraction
tempFolder=/usb_drive/emctools/h4c_images/temp
if [ -f $USB_IMAGER_IMAGE ]
then
echo "Image tar file found: ${USB_IMAGER_IMAGE}"
else
echo "Image tar file not found: ${USB_IMAGER_IMAGE}"
return 1
fi
tmp=`pwd`
# extract
if [ -f $NoExtractionFile ] && [ -d $tempFolder ]
then
echo "No need to extract Image tar file."
cd $tempFolder
else
echo "Extract Image tar file."
mkdir -p $tempFolder
cd $tempFolder
tar -xzvf $USB_IMAGER_IMAGE
fi
# Validate the images
for IMAGE in $IMAGES; do
if [ -f $IMAGE ]
then
local_md5=`md5sum $IMAGE |awk -F ' ' '{print $1}'`
md5_from_tar=`cat $IMAGE".md5"`
if [ "$local_md5" == "$md5_from_tar" ]
then
echo "$IMAGE is valid"
else
echo "$IMAGE is not valid"
cd $tmp
rm -fr /usb_drive/emctools/h4c_images/temp/
return 3
fi
else
echo "$IMAGE Not found in $USB_IMAGER_IMAGE tar file"
cd $tmp
rm -fr /usb_drive/emctools/h4c_images/temp/
return 2
fi
done
cd $tmp
return 0
}
setup_rootfs_to_shutdown()
{
# set up the rootfs just enough to finish the boot
# and shutdown
mkdir /sysroot/bin
cp -r -d /bin/* /sysroot/bin/
mkdir /sysroot/sbin
cp -r -d /sbin/* /sysroot/sbin/
cp -r -d /imager_contents/etc /sysroot/
mkdir -p /sysroot/dev
cp -r -d /dev/* /sysroot/dev/
mkdir -p /sysroot/sys
mkdir -p /sysroot/proc
mkdir -p /sysroot/usr
mkdir -p /sysroot/usr/local
mkdir -p /sysroot/usr/local/cfg/
cp -r -d /imager_contents/initrd_bootstrap.sh /sysroot/usr/local/cfg/
# mount the boot filesystem
mkdir -p sysroot/boot
mkdir -p /sysroot/sysroot
sleep 5
}
enable_network()
{
echo "Enable Network" $1
ethno=$1
ifconfig $ethno up
if [ $? -eq 0 ]
then
sleep 5
udhcpc -t 10 -n -s /etc/network/udhcpc.script -p /var/run/udhcpc.$ethno.pid -i $ethno
sleep 2
fi
ifconfig $ethno
sleep 2
}
###
# Invoke the main USB imaging process.
###
do_usb_imaging()
{
# invoke the actual imager script
/imager_contents/emc_imager.sh usb_imaging $1 $2 $3 $4
setup_rootfs_to_shutdown
echo "Imaging Successful. Please remove the USB drive before the next power on"
}
###
# Normal, platform independent lifeline boot. Mount images
# and set up the rootfs.
###
do_normal_boot()
{
echo "Found Valid EMC Image in disk..."
MNTOPTS=loop
NFSDEBUGMOD=
NFS_SERVER=
NFS_ROOT=/home/soho/soho_root
echo "Mounting apps image..."
mkdir -p sysroot/mnt/apps
if [ "$NFSDEBUGMOD" = "" ]
then
mount -o loop,ro $APPS_IMAGE sysroot/mnt/apps
else
#for NFS debugging
enable_network eth0
echo "mount -t nfs -onolock $NFS_SERVER:$NFS_ROOT sysroot/mnt/apps"
mount -t nfs -onolock $NFS_SERVER:$NFS_ROOT sysroot/mnt/apps
sleep 2
fi
# mount config
echo "Mounting config image..."
losetup /dev/loop1 $CONFIG_IMAGE
# we temporarily symlink /lib and /usr/lib to the apps image, so we can run
# the dynamically linked fsck executable from that location in initrd context
echo "Check config filesystem"
ln -s /sysroot/mnt/apps/lib /lib
mkdir -p /usr
ln -s /sysroot/mnt/apps/usr/lib /usr/lib
e2fsck -y /dev/loop1 > etc/fsck
rm -rf /lib /usr/lib /usr
# mount the writeable image
mkdir -p sysroot/mnt/etc
mount /dev/loop1 sysroot/mnt/etc -o noatime,sync
# mount a unionfs of the RO content and RW image
mkdir -p sysroot/etc
mount -t unionfs none /sysroot/etc -o noatime,sync,dirs=/sysroot/mnt/etc=rw:/sysroot/mnt/apps/etc=ro
# remove old System.map files
rm /sysroot/boot/System.map-*
# copy the System.map file to /boot
echo "Copying System.map..."
SYSTEM_MAP_SRC_NAME="/sysroot/mnt/apps/var/System.map-*"
SYSTEM_MAP_DEST_NAME="/sysroot/boot/"
if [ -f $SYSTEM_MAP_SRC_NAME ]; then
cp -f $SYSTEM_MAP_SRC_NAME $SYSTEM_MAP_DEST_NAME
fi
# mount the branding image if it exists
if [ -f $OEM_IMAGE ]; then
mkdir -p sysroot/oem
mount -o $MNTOPTS sysroot/boot/images/oem sysroot/oem
fi
}
###
# Update an image in NAND flash. Locate the mtd partition by name,
# erase, and reflash.
###
update_flash_image()
{
# search for the image dev by name
mtdname=`grep $1 /proc/mtd | awk -F : '{ print $1 }'`
if [ ! $mtdname ];
then
echo "No Image"
return
fi
# get the major:minor for this mtd dev
major=`cat /sys/class/mtd/$mtdname/dev | awk -F : '{ print $1 }'`
minor=`cat /sys/class/mtd/$mtdname/dev | awk -F : '{ print $2 }'`
# create the dev node, update the image
mknod /dev/$mtdname c $major $minor
flash_eraseall /dev/$mtdname
nandwrite -p /dev/$mtdname $2
}
###
# Copy images from the USB drive to the image
# location on the device.
###
copy_image()
{
IMAGES_DIR=/sysroot/boot/images
SDKAPPS_DIR=/sysroot/boot/SDKApps
SDKAPPS_SOURCE=/usb_drive/emctools/h4c_images/SDKApps
SDK_ETC_DIR=/sysroot/etc
SDK_ETC_SOURCE=/usb_drive/emctools/h4c_images/etc
CONFIG_IMAGE=/sysroot/boot/images/config
mkdir $IMAGES_DIR
cp $APPS_UPGRADE_IMAGE $IMAGES_DIR
cp $CONFIG_UPGRADE_IMAGE $IMAGES_DIR
cp $OEM_UPGRADE_IMAGE $IMAGES_DIR
echo "Copied apps config and oem image"
if [ -f $KERNEL_IMAGE ]
then
cp $KERNEL_IMAGE $IMAGES_DIR
fi
if [ -f $RAMDISK_IMAGE ]
then
cp $RAMDISK_IMAGE $IMAGES_DIR
fi
if [ -d "$SDKAPPS_SOURCE" ]
then
#Copy the SDK Apps
mkdir -p $SDKAPPS_DIR
echo "Copying SDK Apps to $SDKAPPS_DIR"
cp -f $SDKAPPS_SOURCE/* $SDKAPPS_DIR
fi
if [ -d "$SDK_ETC_SOURCE" ]
then
#Copy the SDK ETC
losetup /dev/loop1 $CONFIG_IMAGE
mkdir -p $SDK_ETC_DIR
mount /dev/loop1 $SDK_ETC_DIR -o noatime,sync
echo "Copying SDK Etc to $SDK_ETC_DIR"
cp -f $SDK_ETC_SOURCE/* $SDK_ETC_DIR
sleep 4
umount $SDK_ETC_DIR
fi
}
Here the important part is:
Code:
if [ "$NFSDEBUGMOD" = "" ]
then
mount -o loop,ro $APPS_IMAGE sysroot/mnt/apps
else
#for NFS debugging
enable_network eth0
echo "mount -t nfs -onolock $NFS_SERVER:$NFS_ROOT sysroot/mnt/apps"
mount -t nfs -onolock $NFS_SERVER:$NFS_ROOT sysroot/mnt/apps
sleep 2
fi
This is when I try to see what the variable contains:
I have a ix2-200, similar setup originally. There is a trick on these to getting on root, mounting the image file rw and changing it so that it doesn't get over-written. You might need serial console access if you want to be safe. I'll see if I can find my notes; I got most of them originally over at NAS-Central http://forum.nas-central.org
Unfortunately I got tired of hacking it and ended up installing ARMEDSlack on it, which works much better and is easier to modify (like installing SANE for a network scanner) or to maintain. Of course that's a much bigger and somewhat more drastic step.
WARNING, following the steps below may brick your device.
I haven't found my notes yet, but was thinking about what I did in the past. You didn't say how you were accessing your disks/system. If you take your disks out and connect them another machine to explore them, you should find a software RAID setup, which you should be able to assemble and mount. On that RAID system you should find a directory with the ext2 images of the config and apps directories, which you should be able to mount with -loop as you describe above, rw, and then make the modifications to the files. Unmount the loop devices, unmount the RAID, remove the drives and replace them in your NAS, and reboot. See http://www.krausam.de/?p=33 for some details, though the page only talks about enabling ssh...
For 2 disk RAID 1:
If you want to be safe(r) but don't want to/can't get serial port access to your device, remove the RAID and only modify one of the drives, keeping the other one aside. (You'll have to assemble the RAID with the "missing" parameter) Put the modified disk in and verify it works. If it does, wipe the other disk and rebuild the RAID as though it were a disk replacement. If it doesn't, you should be able to use the disk you put aside. I assume though that the ix4 has 4 disk RAID, setup as RAID-5, which might make this actually less safe than assembling the entire RAID.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.