Recent Updates Page 5 Toggle Comment Threads | Keyboard Shortcuts

  • Urban 03:17 on 15 Nov. 2011 Permalink |  

    Moving Nexenta from HDD to USB stick 

    I wanted this because the 7200 RPM disk that shipped with HP Microserver makes an annoying metallic noise when spinning. USB key is quieter, greener and frees an additional disk bay. Also, Microserver has an extra USB slot inside the chasis just for this purpose.

    However, the operation was not as simple as I thought1 — because you can’t shrink zpools (that is, shrink from the 250GB internal drive to the 16GB USB drive).

    So I had two options: reinstall from scratch and choose USB stick as the target, or move the existing system. I chose the latter to avoid the reconfiguration. However, if you haven’t installed it yet and are thinking about this as a future upgrade path, I recommend you skip the HDD entirely and go directly to USB stick; it will save you a lot of trouble.

    In the end, this process worked:

    • Install Nexenta (fresh install) on USB key (I did this using VMWare and USB passthrough). This creates suitable partition table, installs grub and saves many other steps as well.
    • Boot the old system (disable usb boot) and plug in the USB stick.
    • Import new zpool on the usb stick as newsyspool (to distinguish from old syspool).
    • Delete all filesystems in newsyspool using zfs destroy newsyspool/dump (also: newsyspool/swap, newsyspool/nmu… everything); this deletes all data on the USB drive — we just need partitions (i.e., ZFS slices).
    • Make a recursive snapshot of the old (internal HDD) syspool: zfs snapshot -r syspool@20111112
    • Copy entire internal HDD (i.e., syspool) to the USB stick: zfs send -R syspool@20111112 | zfs recv -vFd newsyspool
    • Set boot property of the USB drive in the same way than that of your internal HDD. Get the latter with zpool get bootfs syspool (this shows old bootfs property, e.g., syspool/rootfs-nmu-000). Then set the former (newsyspool on USB drive) with zpool set bootfs=newsyspool/rootfs-nmu-000 newsyspool
    • Set noatime=off to disable writing a timestamp on every read: zfs set atime=off newsyspool
    • Disconnect your internal HDD, set bios to boot from USB drive and reboot.
    • If the system doesn’t boot, just reconnect the old drive and you haven’t lost anything.
    • If the system boots, delete the old syspool which is now faulted (since there’s no HDD): zpool destroy syspool (warning, this asks for no confirmation! be sure you’ve booted from USB!)

    I got most of it from these guides:

     

    Update 2011-12-20:

    About 1 month after the upgrade the USB key failed; the server wouldn’t boot (stuck at grub loading stage2), so I plugged back the old HDD, scrubbed USB key zpool and it found approx. 1000 errors, of which 500 were unrecoverable. It was not the cheapest USB key (PQI), but the constant swapping or whatever Nexenta’s doing when nobody’s looking must have killed it.

    Update 2012-05-15

    Fixed some errors pointed out in the comment.

    1. What I thought was this: plug in the USB stick, create a mirrored syspool and remove the HDD []
     
    • Roland Hordos 20:30 on 15 May. 2012 Permalink

      Thank you!  This worked for me with a couple of tweaks, then some additional (resolved) drama.

      NexentaStor 3.1.2 – SunOS 5.11 NexentaOS_134f 64bit
      Tweak 1 – The snapshot also needs to be recursive or the send/recv will miss most everything# zfs snapshot -r syspool@20100514-2Tweak 2 – The atime statement for me needed to be:# zfs set atime=off newsyspool  I subsequently decided to revert the atime back to “on” which is what the original syspool has, just in case there’s some algorithm foiled by this and inadvertenly causing _more_ writes (perhaps causing your early device failure?)Problem with Licensing – the mucking with the syspool causes the licensing system to get a headache on reboot and wants you to reenter your registration key.  You do but License bully doesn’t like that you’ve changed the syspool name and errors, forcing you to take a bash shell or return to the licensing screen.Solution:* Booted into recovery console* Imported newsyspool as syspool (needs -f)* Rebooted into appliance, licensing bully faked outI imagine a cleaner way to do this but exporting the in use newsyspool first did not seem viable. Cleanup:  so there’s also still a “newsyspool” because it was never exported and now the metadata is a mess from what I did in recovery console with -f.  Newsyspool is ONLINE and healthy whereas “syspool” is degraded.  Despite degraded it is actually in use as running df in bash shows a syspool originating root mount.  So ..* Exported newsyspool so it’s no longer claiming the same device* Cleared errors on syspool as it has it’s device back* Reboot auto repaired a minor checksum error (declared as such)

      Thank you, this freed the initial 1TB drive I used for my syspool on install.  I then went on to mirror the syspool to further protect my blazing fast NexentaStor !

    • Urban 21:48 on 15 May. 2012 Permalink

      Thanks for the comment, your tweaks are actually the right way to do it.. I’ve updated the post to fix the errors 🙂

    • Roland Hordos 16:33 on 16 May. 2012 Permalink

      Cool!  Sorry for the de-formatted mess I made in your post <>

    • Damian Wojsław 09:30 on 15 Jun. 2012 Permalink

      I think there is lots of logging going on during normal operation, so you’d get lots of write cycles. If your appliance is swapping, I’d say that you have too little RAM for normal operation. 🙂

    • araj 17:21 on 13 Dec. 2012 Permalink

      were you able to exactly figure out  what went wrong while using the USB as boot drive. I am trying to setup a nexentastor based NAS with boot from USB 2x16GB-mirrored, and 8GB RAM

      Any input is much appreciated.The area I am most uncertain about is on safely using the USB flash drive as boot disk.

      Thanks

    • Urban 01:55 on 14 Dec. 2012 Permalink

      Unfortunately, no.. I didn’t have the slightest idea how to approach such post-mortem diagnostics. USB flash drives use wear leveling, which makes the entire drive wear out equally (below the level of FS). This makes it next to impossible to isolate the reason after the fact..

      In hindsight, my best guess is swap (as another commenter noted), which should’ve been disabled (duh). I guess I didn’t think swap would get used that much, as the machine had 8 GB of RAM (which should’ve been plenty). 

      Also note that I used Nexenta Core, which is basically “an ordinary linux distro with solaris kernel”. I would think this is not optimized in any way, out-of-the-box. On the other hand, NexentaStor is a ready-made appliance with all kinds of things preconfigured, so it’s very likely a better starting point and might already be tweaked to play better with flash storage.

      All that said, any flash drive you use will still have a limited number of writes and it will most definitely not be sustainable in the long run if there’s stuff being written to it. If you want a bulletproof solution, you need to mount it in readonly mode and move all writable config files, temp dirs and logs to another drive (you can replace originals with symlinks to the new location). This could very easily prove to be more trouble than is’t worth.. 

      Alternatively, you could use a NAS distro that’s already optimized to run in read-only mode from a flash drive, such as FreeNAS.

      Or just use two HDDs (maybe internal + usb). Or even only 1 HDD with copies=2 to protect against soft errors.. depends on what you want to optimize for.

    • araj 15:24 on 14 Dec. 2012 Permalink

       Thanks a lot for the reply and the suggestions will definitely help me.

  • Urban 01:45 on 30 Sep. 2011 Permalink |  

    A better home server 

    I’ve written about my small and green home server before. I love its low power consumption, integrated UPS/keyboard/screen and the small size.

    But it was time for an upgrade — to a real server.

    Size comparison: HP Microserver vs. Asus EEE

     

    The reasons for an upgrade

    The thing I missed most was more CPU power. The 600 MHz Celeron CPU got pretty bogged down during writes due to NTFS compression. With more and more concurrent writes, the write performance slowed down to a crawl.

    Then there was a shortage of RAM. 1 GB is enough for a single OS, but I’m kind of used to virtualizing stuff. I wanted to run some VMs.

    Also, I’ve been reading a lot about data integrity. This was supposed to be my all-in-one central data repository, but was based on cheap hardware with almost no data protection at all:

    • My single drive could easily fail; it would be nice to have two in a mirror (also, not USB).
    • Bits can randomly and silently flip without leaving any detectable signs (the infamous bit rot).
    • Memory corruption does happen (failing memory modules) and more, bits in RAM flip significantly more often (memory bit rot or soft errors) than on hard drives.

    So what I wanted to combat these problems was:

    • a server that’s still as small, as silent and as green as possible;
    • has a more decent CPU and plenty of RAM;
    • supports ECC RAM (stands for error correcting);
    • and can accomodate an OS with native ZFS file system.

     

    Why worry about data integrity all of a sudden?

    Well, they say the problem’s always been there: bit error rate of disk drives has been almost constant since the dawn of time. On the other hand, disk capacity doubles every 12-18 months.

    This loosely translates to: there’s an unnoticed disk error every 10-20TB. Ten years ago one was unlikely to reach that number, but today you only need to copy your 3TB Mybook three times and you’re likely to have some unnnoticed data corruption somewhere. And in 5-7 years you’ll own a cheap 100TB drive full of data.

    Most of today’s file systems were designed somewhere in the 1980s or early 1990s at best, when we stored our data on 1.44MB floppies and had no idea what a terabyte is. They continue to work, patched1 beyond recognition, but they were not really designed for today’s, let alone tomorrow’s disk sizes and payloads.

     

    Enter ZFS

    ZFS is hands down the most advanced file system in the world. Add to that some other superlatives: the most future proof, enterprise-grade and totally open-source. Its features put any other FS to shame2:

    • it includes a LVM (no more partitions, but storage pools),
    • ensures data integrity by checksumming every block of data, not just metadata,
    • automatically corrects data (for this, you need 2 copies of it — that’s why you need a mirror or copies=N setting with N>1)
    • compresses data (with up to gzip-9), which is extremely useful for archival purposes and also speeds up reads
    • supports on-the-fly deduplication (more info here),
    • has efficient and fast snapshotting,
    • can send filesystems or their deltas to another ZFS or to a file, and re-apply them back,
    • can seamlessly utilize hybrid storage model (cache most used data in RAM, and a little less used data on SSD), which means it’s blazingly fast3,
    • integrates iSCSI, SMB (in the FS itself), supports quotas, and more.

    Of course ZFS can use as much ram as possible for cache, plus about 1GB per 1TB of data for storing deduplication hashes. And since the integrity of data is ensured on the drive, it would be a shame for it to get corrupted in RAM (hence, ECC RAM is a must).

     

    The setup

    Getting all this packed inside a single box looked like an impossible goal — until I found the HP Proliant Misroserver. You can check the review that finally convinced me below.

    The specs are not stellar, but it provides quite a bang for the buck4.

    • It’s a nice and small tower of 27 x 26 x 21 cm with 4 externally accessible drive bays and ECC RAM support;
    • CPU is arguably its weakest point: Dual-core AMD N36L (2x 1.3 GHz); however, the obvious advantage of AMD over Atoms is ECC support;
    • It includes a 250GB drive and 1GB ram, but I’ve upgraded that.
    • upgrade 1: 2x 4GB of ECC ram; as I said, ECC is a must for a server, where a bit flip in memory can wreak havoc in a file system that is basically a sky-high stack of compressed and deduplicated snapshots.
    • upgrade 2: 2x 2TB WD green; it’s energy efficient and can be reprogrammed to avoid aggressive spin-downs.
    • All together, the server loaded with 3 drives consumes only 45W. It’s not silent, but it’s pretty quiet.

    Here’s a quick rundown of what I’ve done with it, mostly following this excellent tutorial (but avoiding the potentially dangerous 4k sector optimization):

    • I installed Nexenta Core, which is a distro combining Solaris kernel with Ubuntu userland. I’ve read many good things about it and find it more intuitive and lean than Solaris.
    • Note: as Nexenta currently doesn’t support booting from a USB key, I had to use an external CD drive, which I hacked from a normal CD drive and an IDE-to-USB cable.
    • I reconfigured WD Green HDDs to disable frequent spindowns.
    • But: I avoided fiddling with the zpool binary from the tutorial above because it can cause compatibility issues and data loss and brings little improvement.
    • I finally added the excellent napp-it web GUI for basic web management. This comes pretty close to a home NAS appliance with the geek factor turned up to 11. You can monitor and control pretty much everything you wish (see below for a screenshot).

    Napp-it web GUI -- pool statistics

    I configured two drives as a mirrored pool and created a bunch of filesystems in it. A ZFS filesystem is quite analogous to a regular directory and you can have as many filesystems (even nested ones) as you wish. Each separate ZFS can have individual compression, deduplication, sharing and mount point settings (however, deduplication itself is pool-wide).

    Just for feeling, the deduplication and compression at work: with about 630GB of data currently on it (of which there’s about 500GB of Vmware backup images of three servers), the actual space occupied is 131 GB.

    urban@titan:~$ zpool list
    NAME      SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
    syspool   232G  6.96G   225G     2%  1.00x  ONLINE  -
    tank     1.81T   131G  1.68T     7%  2.13x  ONLINE  -

    If we look at zpool debugger stats about compression and deduplication, we see there’s a lot of both going on:

    urban@titan:~$ sudo zdb -D tank
    DDT-sha256-zap-duplicate: 695216 entries, size 304 on disk, 161 in core
    DDT-sha256-zap-unique: 1122849 entries, size 337 on disk, 208 in core
    
    dedup = 2.13, compress = 2.04, copies = 1.00, dedup * compress / copies = 4.35

     

    From here on

    So far I’ve been more than satisfied. I’ve written about deduplication before, and this here is by far the most elegant and robust solution. Of course there’s a bunch of stuff to do next.

    The first one is virtualization, and here my only option (this being a Solaris kernel) is Virtualbox. Until now I’ve sworn by Vmware, but image conversion is actually pretty straightforward (using the qemu-img tool).

    The first candidate for virtualization will be my old EEE, because I still need Windows for running a couple of Windows-only services. The virtual EEE should also be able to mount the ZFS below, either via SMB or iSCSI (Microsoft does provide free iSCSI initiator which I’ve successfully used before), which should ensure smooth transition to the new server.

    1. look at how FAT32 added long file names to see what I mean. []
    2. for detailed FS feature comparison check Wikipedia []
    3. check here: http://www.anandtech.com/show/3963/zfs-building-testing-and-benchmarking/8, but look at OpenSolaris curve; Nexenta here stands for NexentaStor appliance, which is a commercial product. Open-source Nexenta Core actually beats both NexentaStor and OpenSolaris. []
    4. Its current price is mere 169 EUR at very customer-friendly hoh.de. []
     
  • Urban 23:39 on 31 Jul. 2011 Permalink |  

    Skip Trash in Lion 

    One of the things that bothers me in Mac OS X is that you cannot delete files without skipping the trash (apart from using the console). This means that to free the disk space of, say, a 2GB file, you have to empty the trash; if you delete large files often, your trash either grows very large or you empty it so often, that it defeats the very purpose of having one.

    Until now I’ve used a handy script/droplet Permanently shred, but it broke in Lion. So here’s how you make your own “Skip Trash” dock app using Automator.

    1. Start Automator
    2. Choose “Application”

     

    3. Search for “Ask for confirmation” and drag it to the right pane
    4. Enter a confirmation message, e.g. “Are you sure?”

    5. Search for “Run shell script” and drag it to the right pane
    6. Select “Pass input: as arguments”
    7. Replace “echo” with “rm -rf”

    8. Save application (e.g. as SkipTrash.app)
    9. drag it to the dock and select “Options -> keep in dock”

    If you want the app to play a Poof sound when finished, add “afplay /Library/poof.aif” at the end of the shell script and unzip and copy this file to your /Library/ (or any other location you want, but update the path accordingly): poof.aif.zip

    So now whenever you want to skip the trash, drop files or folders onto the newly created SkipTrash.app instead of the regular Trash icon.

     
    • Taoiste 02:41 on 9 Sep. 2011 Permalink

      Works great, thanks, but with only one file at a time.
      I’m trying to figure out how to prevent Lion from asking “Run anyway, because it’s from internet…”

    • Urban 17:25 on 9 Sep. 2011 Permalink

      It should work for more than one file.. make sure you’ve selected “pass input as arguments” and put the rm -rf inside the *for loop*.
      If the soundfile’s giving you problems, you can just omit it. Otherwise, try something like this to disable warnings: 
      https://discussions.apple.com/thread/3216314?start=0&tstart=0 

    • Urban 17:26 on 9 Sep. 2011 Permalink

      It should work for more than one file.. make sure you’ve selected “pass input as arguments” and put the rm -rf inside the *for loop*.

      If the soundfile’s giving you problems, you can just omit it. Otherwise, try something like this to disable warnings: 
      https://discussions.apple.com/thread/3216314?start=0&tstart=0 

    • Taoiste 18:17 on 9 Sep. 2011 Permalink

      Typed in terminal: defaults write com.apple.LaunchServices LSQuarantine -bool NO
      Now it works now with more than one file. Thanks alot!

    • robotwholearned 17:18 on 8 Jun. 2012 Permalink

      Thank you, this works great!

  • Urban 02:10 on 19 Jul. 2011 Permalink |  

    O knjigarnah 

    Ko smo se potikali po ZDA, sem večkrat zataval v knjigarno Borders, ki je s svojim umirjenim ambientom, bolj podobnim knjižnici, kot pa knjigarni, predstavljala oazo sredi hektičnega mesta. Klima, zastonj internet in vse knjige, ki jih je poželelo srce, tako da sploh nisem vedel kaj bi prej vzel v roke; večkrat sem se zalotil pri tuhtanju, kako bi domov odvlekel večji kup knjig, pa sem se hitro streznil, češ da take kupe doma že imam, pa jih sploh še nisem prebral.

    Borders je že februarja oznanil bankrot, ker pa do zdaj niso našli kupca, dokončno zapirajo vrata. In ne morem reči, da nisem tudi sam pomagal pri njihovem propadu. Par dobrih knjig sem našel tam, pa sem jih kar sproti kupil v Amazonovem Kindle Storu, preko iPhona in Bordersovega brezplačnega WiFi-ja. Pa še malo počíl in se lahkih rok podal naprej. Dvomim da sem bil edini.

    Čeprav vem, da se pol tisočletja stari tehnologiji tiska počasi bliža konec, ter so mi znane prednosti prenosne knjižnice, pa se mi takih kotičkov vseeno zdi škoda. Pasovna širina interakcije™ je v knjigarni mnogo večja kot na spletu. Uporabiš lahko roke, noge, ter se prebiješ čez celo knjigarno v nekaj minutah. Najdeš zanimiv oddelek, kjer se lahko ustaviš, pri tem pa s pogledom oplaziš na stotine knjig1.

    Na spletu smo še vedno v kameni dobi. Page 1 of 145. Next.

    Seveda knjigarne iz opeke in malte ne bodo odšle čez noč. Borders ni bila niti največja ameriška veriga (Barnes&Noble je še večji). Ampak posel ne bo iz dneva v dan lažji, občutki pa ne povsem različni od čakanja pred strelskim vodom.

    1. Pri nas recimo mi je izredno všeč ValeNovak, kjer lahko najdeš tudi tako sodobne naslove kot so XKCD, Dilbert in zbrane objave z blogov Setha Godina. []
     
    • Metatronbozo 08:19 on 19 Jul. 2011 Permalink

      a Vale Novak še obstaja? A ni vse njegove knigarne prevzela Mladinska knjiga… sem neki o tem slišal, ko so ljudje sedaj čisto razočarani, ker ne morejo več naročevat kakšne posebne knjige al pa revije (kar jim je VN prej omogočal)

    • Urban 10:56 on 19 Jul. 2011 Permalink

      pa res, cist sm spregledal. zdej pa vidm da se tud oni mel fajn izgubo.. RIP

  • Urban 23:54 on 11 Jul. 2011 Permalink |  

    Server status via SMS 

    Stormy weather makes me worried about my electronic equipment, especially servers. A summer storm can take out power, corrupt a HDD in the process, or in the worst case, fry absolutely everything by a strategically placed lightning strike.

    But even on a quiet winter day, hard disk can quietly fill with logs, one byte at a time, finally causing a bunch of services to die (I’m looking at you, Mysql).

    The point is, anything can happen and you have to check often to prevent an unplanned downtime, which can sometimes extend significantly because no-one checked1. And checking gets more tedious the more stuff you have. So this post describes a quick&dirty method, tailored to my needs, on the cheap.

    A quick disclaimer: I do know about Pingdom and similar services, as well as Nagios. However, I wanted a simple lightweight script, which runs on my home server behind a firewall, and queries my public servers over HTTP. Then it sends me a text, once daily.

    This is how it works:

    • my home server acts as an agent and tries to contact all the public servers
    • each server performs a quick and dirty on-demand self-test, responding with a message that reports the available disk space, mysql status, etc.
    • python script on the home server aggregates all the responses into a concise form, suitable for texting
    • and sends it, once a day.

    To test the public servers, I created a simple PHP script which performs some basic tasks a healthy server should be able to do, and returns a response. This is the version 1:

    
    A<?php
        /*A stands for Apache.
          If only "A" gets served,
          the web server is alive, but PHP doesn't work. */
     
        /*print P (short for PHP OK),
          followed by GBs of free disk space */
        echo "P[" . floor(disk_free_space("/") / 1024 / 1024 / 1024) . "G]";
    
    
        /*try connecting to MySQL */
        mysql_connect("server", "user", "pass")
            or die("db_down");
        mysql_select_db("mysql")
            or die("db_err");
      
        /*Print a short string ("My") through the
          database to prove it works.*/
        $res = mysql_query("select 'My' as my from user");
        $row = mysql_fetch_assoc($res);
        echo $row["my"];
    
    
        /*if everything works ok, this should
          return something like AP[10G]My
          which simply means apache works ok,
          php interpreter is fine,
          there's 10G of free disk
          and mysql is fine. */
    ?>
    
    

    I wanted to get this summary delivered as a SMS notification. Twillio looked promising, but in the end wouldn’t take my CC, so I used this awesome hack to send free text in the form of a Google Calendar reminder.

    I extended the provided Python script to also get the free disk space of my home server and wrap everything up as a single SMS. The result looks something like this:

    Reminder: srv1_ok! c:1018M d:709054M srv2:AP[10G]My srv3:AP[2G]My

    This was at first meant to be just a form of “infrastructure unit test”, returning true if everything checks out OK, and false otherwise. But since there was room for additional info, I added more to fill the message.

    I’ve been somewhat reluctant to set up different notifications in the past, because that basically means more spam. But since I did it once at work (via e-mail), it’s been quite satisfying. An e-mail with the subject “Everything ok!” makes my day, and that’s what I get most of the time anyway.

    1. It’s just recently happened to me 🙂 []
     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel